mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-07-04 22:10:56 +12:00
Attempt to fix zsh issues
This commit is contained in:
parent
cc1fb789c6
commit
55dc32bacc
|
@ -44,7 +44,7 @@ public class ScriptHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String constructInitFile(
|
public static String constructInitFile(
|
||||||
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login, String displayName) {
|
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login, String displayName) throws Exception {
|
||||||
ShellDialect t = processControl.getShellDialect();
|
ShellDialect t = processControl.getShellDialect();
|
||||||
String nl = t.getNewLine().getNewLineString();
|
String nl = t.getNewLine().getNewLineString();
|
||||||
var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl;
|
var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl;
|
||||||
|
@ -71,7 +71,7 @@ public class ScriptHelper {
|
||||||
content += t.getExitCommand() + nl;
|
content += t.getExitCommand() + nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
var initFile = createExecScript(processControl, content);
|
var initFile = createExecScript(processControl, t.initFileName(processControl), content);
|
||||||
return initFile;
|
return initFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class ScriptHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private static String createExecScript(ShellControl processControl, String file, String content) {
|
public static String createExecScript(ShellControl processControl, String file, String content) {
|
||||||
ShellDialect type = processControl.getShellDialect();
|
ShellDialect type = processControl.getShellDialect();
|
||||||
content = type.prepareScriptContent(content);
|
content = type.prepareScriptContent(content);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import java.util.stream.Stream;
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||||
public interface ShellDialect {
|
public interface ShellDialect {
|
||||||
|
|
||||||
|
String initFileName(ShellControl sc) throws Exception;
|
||||||
|
|
||||||
CommandControl directoryExists(ShellControl shellControl, String directory);
|
CommandControl directoryExists(ShellControl shellControl, String directory);
|
||||||
|
|
||||||
CommandControl normalizeDirectory(ShellControl shellControl, String directory);
|
CommandControl normalizeDirectory(ShellControl shellControl, String directory);
|
||||||
|
|
|
@ -5,6 +5,8 @@ import io.xpipe.core.process.OsType;
|
||||||
import io.xpipe.core.process.ShellControl;
|
import io.xpipe.core.process.ShellControl;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class XPipeTempDirectory {
|
public class XPipeTempDirectory {
|
||||||
|
|
||||||
|
@ -12,9 +14,10 @@ public class XPipeTempDirectory {
|
||||||
return proc.getOsType().getTempDirectory(proc);
|
return proc.getOsType().getTempDirectory(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSubDirectory(ShellControl proc) throws Exception {
|
public static String getSubDirectory(ShellControl proc, String... sub) throws Exception {
|
||||||
var base = proc.getOsType().getTempDirectory(proc);
|
var base = proc.getOsType().getTempDirectory(proc);
|
||||||
var dir = FileNames.join(base, "xpipe");
|
var arr = Stream.concat(Stream.of(base, "xpipe"), Arrays.stream(sub)).toArray(String[]::new);
|
||||||
|
var dir = FileNames.join(arr);
|
||||||
|
|
||||||
if (!proc.getShellDialect().createFileExistsCommand(proc, dir).executeAndCheck()) {
|
if (!proc.getShellDialect().createFileExistsCommand(proc, dir).executeAndCheck()) {
|
||||||
proc.executeSimpleCommand(
|
proc.executeSimpleCommand(
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class OpenFileWithAction implements LeafAction {
|
||||||
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||||
var os = model.getFileSystem().getShell();
|
var os = model.getFileSystem().getShell();
|
||||||
return os.isPresent()
|
return os.isPresent()
|
||||||
&& !os.get().getOsType().equals(OsType.MACOS)
|
&& os.get().getOsType().equals(OsType.WINDOWS)
|
||||||
&& entries.size() == 1
|
&& entries.size() == 1
|
||||||
&& entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
|
&& entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue