Skip to content

Commit 47969b6

Browse files
Fix for iTerm quiet opening config (#64)
Co-authored-by: Vítor Galvão <[email protected]>
1 parent c082d89 commit 47969b6

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

custom_iterm_script.applescript

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ property open_in_new_window : false
77
-- Set this property to false to reuse current tab
88
property open_in_new_tab : true
99

10+
-- Set this property to true if iTerm is configured to launch without opening a new window
11+
property iterm_opens_quietly : false
12+
1013
-- Handlers
1114
on new_window()
1215
tell application "iTerm" to create window with default profile
@@ -54,20 +57,25 @@ on alfred_script(query)
5457
-- Reuse current tab
5558
end if
5659
else
57-
-- If iTerm is not running and we tell it to create a new window, we get two
58-
-- One from opening the application, and the other from the command
59-
if is_running() then
60+
-- If iTerm is not running and we tell it to create a new window, we get two:
61+
-- one from opening the application, and the other from the command
62+
if is_running() or iterm_opens_quietly then
6063
new_window()
6164
else
6265
call_forward()
6366
end if
6467
end if
6568

6669
-- Make sure a window exists before we continue, or the write may fail
67-
repeat until has_windows()
70+
-- "with timeout" does not work with a "repeat"
71+
-- Delay of 0.01 seconds repeated 500 times means a timeout of 5 seconds
72+
repeat 500 times
73+
if has_windows() then
74+
send_text(query)
75+
call_forward()
76+
exit repeat
77+
end if
78+
6879
delay 0.01
6980
end repeat
70-
71-
send_text(query)
72-
call_forward()
7381
end alfred_script

0 commit comments

Comments
 (0)