From cdb0d02ad58afe23d37fc2df694bd502d1717452 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 22 May 2023 16:24:20 +0000 Subject: [PATCH] Small macOS init file fixes --- .../xpipe/app/prefs/ExternalTerminalType.java | 24 ++++++++----------- .../java/io/xpipe/app/util/ScriptHelper.java | 12 +++++----- 2 files changed, 16 insertions(+), 20 deletions(-) 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 f92aa6c4..d4960dbe 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalTerminalType.java @@ -235,28 +235,23 @@ public interface ExternalTerminalType extends PrefsChoiceValue { @Override public void launch(String name, String file, boolean elevated) throws Exception { try (ShellControl pc = LocalStore.getShell()) { + // TODO: Wait for launch. But how? pc.osascriptCommand(String.format( """ - if application "iTerm" is running then - tell application "iTerm" - set newWindow to (create window with default profile) - tell current session - write text "%s" - end tell - end tell - else - activate application "iTerm" + if application "iTerm" is not running then + launch application "iTerm" delay 1 tell application "iTerm" - tell current window - tell current session - write text "%s" - end tell + tell current tab of current window + close end tell end tell end if + tell application "iTerm" + create window with default profile command "%s" + end tell """, - file.replaceAll("\"", "\\\\\""), file.replaceAll("\"", "\\\\\""))) + file.replaceAll("\"", "\\\\\""))) .execute(); } } @@ -283,6 +278,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue { tell application "System Events" tell process "Warp" keystroke "%s" + delay 0.01 key code 36 end tell end tell 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 4ec5bd7b..c6ce62ec 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -53,15 +53,15 @@ public class ScriptHelper { content = t.changeTitleCommand(displayName) + "\n" + content; } + var applyRcCommand = t.applyRcFileCommand(); + if (applyRcCommand != null) { + content = content + "\n" + applyRcCommand; + } + if (login) { var applyProfilesCommand = t.applyProfileFilesCommand(); if (applyProfilesCommand != null) { - content = applyProfilesCommand + "\n" + content; - } - } else { - var applyRcCommand = t.applyRcFileCommand(); - if (applyRcCommand != null) { - content = applyRcCommand + "\n" + content; + content = content + "\n" + applyProfilesCommand; } }