Skip to content

Commit 32af606

Browse files
committed
Improve reliability of tab creation
We now make sure that Terminal is active before using the tab creation shortcut. However there is still an issue if the user hasn't released the modifier keys used to initiate the command.
1 parent c1077db commit 32af606

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Commands/Open directory in Terminal.plist

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ end
3030
3131
def terminal_script_new_tab(dir)
3232
return <<-APPLESCRIPT
33-
tell application "Terminal" to activate
34-
tell application "System Events"
35-
tell process "Terminal" to keystroke "t" using command down
36-
end tell
37-
tell application "Terminal"
38-
do script "cd #{e_as(e_sh(dir))}; clear; pwd" in the last tab of window 1
39-
end tell
33+
tell application "Terminal"
34+
activate
35+
tell application "System Events"
36+
repeat while "Terminal" is not name of (process 1 where frontmost is true)
37+
delay 0.1
38+
end repeat
39+
tell process "Terminal" to keystroke "t" using command down
40+
end tell
41+
do script "cd #{e_as(e_sh(dir))}; clear; pwd" in the last tab of window 1
42+
end tell
4043
APPLESCRIPT
4144
end
4245

0 commit comments

Comments
 (0)