Small macOS init file fixes

This commit is contained in:
crschnick 2023-05-22 16:24:20 +00:00
parent fbad0be1e2
commit cdb0d02ad5
2 changed files with 16 additions and 20 deletions

View file

@ -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

View file

@ -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;
}
}