File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ on is_running()
2727 application " iTerm" is running
2828end is_running
2929
30+ on is_processing ()
31+ tell application " iTerm" to tell the first window to tell current session to return is processing
32+ end is_processing
33+
3034on has_windows ()
3135 if not is_running() then return false
3236
@@ -66,9 +70,17 @@ on alfred_script(query)
6670 end if
6771 end if
6872
73+ -- macOS buffers TTY input to 1024 bytes, so if input is larger wait for session to be ready
74+ -- "with timeout" does not work with "repeat", so use a delay (0.01 * 500 means a timeout of 5 seconds)
75+ if length of query > 1024
76+ repeat 500 times
77+ if not is_processing() then exit repeat
78+ delay 0.01
79+ end repeat
80+ end if
81+
6982 -- Make sure a window exists before we continue, or the write may fail
70- -- "with timeout" does not work with a "repeat"
71- -- Delay of 0.01 seconds repeated 500 times means a timeout of 5 seconds
83+ -- "with timeout" does not work with "repeat", so use a delay (0.01 * 500 means a timeout of 5 seconds)
7284 repeat 500 times
7385 if has_windows() then
7486 send_text(query)
You can’t perform that action at this time.
0 commit comments