-
Notifications
You must be signed in to change notification settings - Fork 0
/
iterm.scpt
32 lines (31 loc) · 894 Bytes
/
iterm.scpt
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
on run argv
set onlywindow to false
tell application "iTerm"
activate
try
select first window
set onlywindow to true
on error
create window with default profile
select first window
set onlywindow to true
end try
tell the first window
if onlywindow is false then
create tab with default profile
end if
set t to (my findReplace((item 1 of argv), " ", "\\ "))
set t to (my findReplace(t, "(", "\\("))
set t to (my findReplace(t, ")", "\\)"))
tell current session to write text t
end tell
end tell
end run
on findReplace(t, toFind, toReplace)
set {tid, text item delimiters} to {text item delimiters, toFind}
set t to text items of t
set text item delimiters to toReplace
set t to t as text
set text item delimiters to tid
return t
end findReplace