From 63269bbbfb1bfcbd652dba82dc7287d37d584558 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 14 Aug 2023 17:16:50 +0000 Subject: [PATCH] Rework script building --- .../java/io/xpipe/app/util/ScriptHelper.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 2813309f6..46b590d66 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -52,24 +52,26 @@ public class ScriptHelper { public static String constructInitFile(ShellDialect t, ShellControl processControl, List init, String toExecuteInShell, boolean login, String displayName) throws Exception { String nl = t.getNewLine().getNewLineString(); - var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl; - - if (displayName != null) { - content = t.changeTitleCommand(displayName) + "\n" + content; - } + var content = ""; var applyRcCommand = t.applyRcFileCommand(); if (applyRcCommand != null) { - content = content + "\n" + applyRcCommand + "\n"; + content = content + nl + applyRcCommand + nl; } // We just apply the profile files always, as we can't be sure that they definitely have been applied. // Especially if we launch something that is not the system default shell var applyProfilesCommand = t.applyProfileFilesCommand(); if (applyProfilesCommand != null) { - content = content + "\n" + applyProfilesCommand + "\n"; + content = content + nl + applyProfilesCommand + nl; } + if (displayName != null) { + content = t.changeTitleCommand(displayName) + nl + content; + } + + content += String.join(nl, init.stream().filter(s -> s != null).toList()) + nl; + if (toExecuteInShell != null) { // Normalize line endings content += String.join(nl, toExecuteInShell.lines().toList()) + nl;