forked from vitorgalvao/custom-alfred-iterm-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_iterm_script_iterm_2.1.1.applescript
39 lines (37 loc) · 1.19 KB
/
custom_iterm_script_iterm_2.1.1.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- This is v0.4 of the custom script for AlfredApp for iTerm 2.1.1
-- Please see https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/
-- for the latest changes.
-- Please note, if you store the iTerm binary in any other location than the Applications Folder
-- please ensure you update the two locations below (in the format of : rather than / for folder dividers)
-- this gets around issues with AppleScript not handling things well if you have two iTerm binaries on your system... which can happen :D
on alfred_script(q)
if application "iTerm" is running then
run script "
on run {q}
tell application \":Applications:iTerm.app\"
activate
try
set myterm to the first terminal
on error
set myterm to (make new terminal)
end try
tell myterm
set mysession to (launch session \"Default Session\")
tell mysession to write text q
end tell
end tell
end run
" with parameters {q}
else
run script "
on run {q}
tell application \":Applications:iTerm.app\"
activate
tell the first terminal
tell the last session to write text q
end tell
end tell
end run
" with parameters {q}
end if
end alfred_script