diff --git a/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java index b72e5b11..f3886a5a 100644 --- a/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java @@ -2,6 +2,7 @@ package io.xpipe.app.exchange; import io.xpipe.beacon.BeaconHandler; import io.xpipe.beacon.exchange.LaunchExchange; +import io.xpipe.core.process.TerminalInitScriptConfig; import io.xpipe.core.store.LaunchableStore; import java.util.Arrays; @@ -15,7 +16,7 @@ public class LaunchExchangeImpl extends LaunchExchange public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { var store = getStoreEntryById(msg.getId(), false); if (store.getStore() instanceof LaunchableStore s) { - var command = s.prepareLaunchCommand().prepareTerminalOpen(store.getName()); + var command = s.prepareLaunchCommand().prepareTerminalOpen(TerminalInitScriptConfig.ofName(store.getName())); return Response.builder().command(split(command)).build(); } diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java index f862fe7d..e90cad94 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java @@ -580,6 +580,10 @@ public interface ExternalTerminalType extends PrefsChoiceValue { return true; } + default boolean shouldClear() { + return true; + } + default void launch(LaunchConfiguration configuration) throws Exception {} class MacOsTerminalType extends ExternalApplicationType.MacApplication implements ExternalTerminalType { @@ -706,6 +710,11 @@ public interface ExternalTerminalType extends PrefsChoiceValue { super("app.warp", "Warp"); } + @Override + public boolean shouldClear() { + return false; + } + @Override public void launch(LaunchConfiguration configuration) throws Exception { if (!MacOsPermissions.waitForAccessibilityPermissions()) { diff --git a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java index 03ba7fcf..ff27a137 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -1,12 +1,9 @@ package io.xpipe.app.util; import io.xpipe.app.issue.TrackEvent; +import io.xpipe.core.process.*; import io.xpipe.core.store.FileNames; import io.xpipe.core.store.LocalStore; -import io.xpipe.core.process.OsType; -import io.xpipe.core.process.ShellControl; -import io.xpipe.core.process.ShellDialect; -import io.xpipe.core.process.ShellDialects; import io.xpipe.core.util.SecretValue; import lombok.SneakyThrows; @@ -44,18 +41,18 @@ public class ScriptHelper { } } - public static String constructInitFile(ShellControl processControl, List init, String toExecuteInShell, String displayName) + public static String constructInitFile(ShellControl processControl, List init, String toExecuteInShell, TerminalInitScriptConfig config) throws Exception { - return constructInitFile(processControl.getShellDialect(), processControl, init, toExecuteInShell, displayName); + return constructInitFile(processControl.getShellDialect(), processControl, init, toExecuteInShell, config); } - public static String constructInitFile(ShellDialect t, ShellControl processControl, List init, String toExecuteInShell, String displayName) + public static String constructInitFile(ShellDialect t, ShellControl processControl, List init, String toExecuteInShell, TerminalInitScriptConfig config) throws Exception { String nl = t.getNewLine().getNewLineString(); var content = ""; var clear = t.clearDisplayCommand(); - if (clear != null) { + if (clear != null && config.isClearScreen()) { content += clear + nl; } @@ -71,8 +68,8 @@ public class ScriptHelper { content += nl + applyProfilesCommand + nl; } - if (displayName != null) { - content += nl + t.changeTitleCommand(displayName) + nl; + if (config.getDisplayName() != null) { + content += nl + t.changeTitleCommand(config.getDisplayName()) + nl; } content += nl + String.join(nl, init.stream().filter(s -> s != null).toList()) + nl; diff --git a/app/src/main/java/io/xpipe/app/util/TerminalHelper.java b/app/src/main/java/io/xpipe/app/util/TerminalHelper.java index 4e008787..5eccc1dd 100644 --- a/app/src/main/java/io/xpipe/app/util/TerminalHelper.java +++ b/app/src/main/java/io/xpipe/app/util/TerminalHelper.java @@ -7,13 +7,13 @@ import io.xpipe.app.prefs.ExternalTerminalType; import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStoreEntry; import io.xpipe.core.process.ProcessControl; +import io.xpipe.core.process.TerminalInitScriptConfig; import java.io.IOException; public class TerminalHelper { public static void open(String title, ProcessControl cc) throws Exception { - var command = cc.prepareTerminalOpen(title); open(null, title, cc); } @@ -29,7 +29,7 @@ public class TerminalHelper { : ""; var cleanTitle = (title != null ? title : entry != null ? entry.getName() : "?"); var adjustedTitle = prefix + cleanTitle; - var file = ScriptHelper.createLocalExecScript(cc.prepareTerminalOpen(adjustedTitle)); + var file = ScriptHelper.createLocalExecScript(cc.prepareTerminalOpen(new TerminalInitScriptConfig(adjustedTitle, type.shouldClear()))); var config = new ExternalTerminalType.LaunchConfiguration(entry != null ? color : null, adjustedTitle, cleanTitle, file); try { type.launch(config); diff --git a/core/src/main/java/io/xpipe/core/process/ProcessControl.java b/core/src/main/java/io/xpipe/core/process/ProcessControl.java index e866e7a4..c9e4960f 100644 --- a/core/src/main/java/io/xpipe/core/process/ProcessControl.java +++ b/core/src/main/java/io/xpipe/core/process/ProcessControl.java @@ -16,7 +16,7 @@ public interface ProcessControl extends AutoCloseable { void resetData(); - String prepareTerminalOpen(String displayName) throws Exception; + String prepareTerminalOpen(TerminalInitScriptConfig config) throws Exception; void closeStdin() throws IOException; diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index 3635ec25..fcf9efbf 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -76,9 +76,9 @@ public interface ShellControl extends ProcessControl { ShellControl withErrorFormatter(Function formatter); - String prepareTerminalOpen(String displayName) throws Exception; + String prepareTerminalOpen(TerminalInitScriptConfig config) throws Exception; - String prepareIntermediateTerminalOpen(String content, String displayName) throws Exception; + String prepareIntermediateTerminalOpen(String content, TerminalInitScriptConfig config) throws Exception; String getSystemTemporaryDirectory(); diff --git a/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java b/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java new file mode 100644 index 00000000..5a4ab4c0 --- /dev/null +++ b/core/src/main/java/io/xpipe/core/process/TerminalInitScriptConfig.java @@ -0,0 +1,14 @@ +package io.xpipe.core.process; + +import lombok.Value; + +@Value +public class TerminalInitScriptConfig { + + public static TerminalInitScriptConfig ofName(String name) { + return new TerminalInitScriptConfig(name, true); + } + + String displayName; + boolean clearScreen; +} diff --git a/dist/changelogs/1.7.9.md b/dist/changelogs/1.7.9.md index f503724c..3154b9a8 100644 --- a/dist/changelogs/1.7.9.md +++ b/dist/changelogs/1.7.9.md @@ -11,6 +11,8 @@ If you chose to use an SSH git URL, you can also set key-based authentication op Lastly, there is now a general data directory as well in which you can put any additional files like SSH keys that you want to include in the repository. You can then refer to them just as normal within XPipe but their file paths are automatically adapted on any system you clone the repository. You can open this data directory from the settings menu. +It is recommended to start with the git repository from scratch though to it properly fix past issues. + ### Other changes - Fix some windows being shown outside of screen bounds when display scaling values were set very high