From 82b501d4cc79016dc46288c74913d18bb00d6aee Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 29 Aug 2024 02:09:34 +0000 Subject: [PATCH] Fix term fallback --- .../app/beacon/impl/SshLaunchExchangeImpl.java | 4 +++- .../xpipe/app/terminal/ExternalTerminalType.java | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/SshLaunchExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/SshLaunchExchangeImpl.java index e990553c3..5ba47dbe9 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/SshLaunchExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/SshLaunchExchangeImpl.java @@ -7,12 +7,14 @@ import io.xpipe.beacon.api.SshLaunchExchange; import io.xpipe.core.process.ProcessControlProvider; import io.xpipe.core.process.ShellDialects; +import java.util.List; + public class SshLaunchExchangeImpl extends SshLaunchExchange { @Override public Object handle(HttpExchange exchange, Request msg) throws Exception { if ("echo $SHELL".equals(msg.getArguments())) { - return "/bin/bash"; + return Response.builder().command(List.of("echo", "/bin/bash")).build(); } var usedDialect = ShellDialects.getStartableDialects().stream() diff --git a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java index 7ec8c50a8..0e7e39936 100644 --- a/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/terminal/ExternalTerminalType.java @@ -72,7 +72,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { static ExternalTerminalType determineNonSshBridgeFallback(ExternalTerminalType type) { if (type == XSHELL || type == MOBAXTERM || type == SECURECRT) { - return CMD; + return ProcessControlProvider.get().getEffectiveLocalDialect() == ShellDialects.CMD ? CMD : POWERSHELL; } if (type != TERMIUS) { @@ -90,7 +90,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { return MACOS_TERMINAL; } case OsType.Windows windows -> { - return CMD; + return ProcessControlProvider.get().getEffectiveLocalDialect() == ShellDialects.CMD ? CMD : POWERSHELL; } } } @@ -270,7 +270,10 @@ public interface ExternalTerminalType extends PrefsChoiceValue { .add("\"$(cygpath \"" + b.getIdentityKey().toString() + "\")\"") .add("-p") .add("" + b.getPort()); - var script = ScriptHelper.createExecScript(ShellDialects.BASH, sc, command.buildFull(sc)); + // Don't use local shell to build as it uses cygwin + var rawCommand = command.buildSimple(); + var script = ScriptHelper.getExecScriptFile(sc, "sh"); + Files.writeString(Path.of(script.toString()), rawCommand); var fixedFile = script .toString() .replaceAll("\\\\", "/") @@ -299,7 +302,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { yield CommandSupport.isInPathSilent(sc, "termius"); } case OsType.MacOs macOs -> { - yield CommandSupport.isInPathSilent(sc, "termius"); + yield Files.exists(Path.of("/Applications/Termius.app")); } case OsType.Windows windows -> { var r = WindowsRegistry.local() @@ -1027,8 +1030,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue { XTERM, DEEPIN_TERMINAL, FOOT, - Q_TERMINAL, - TERMIUS); + Q_TERMINAL + ); List MACOS_TERMINALS = List.of( KittyTerminalType.KITTY_MACOS, WARP,