forked from adamwathan/sublime-phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_command.applescript
48 lines (43 loc) · 1.07 KB
/
run_command.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
40
41
42
43
44
45
46
47
48
on execInNewTab(_title, _command)
tell application "Terminal"
activate
set settings to "Basic"
set currentTab to do script _command
end
end execInNewTab
on execInTerminalTab(_command, _window, _tab)
tell application "Terminal"
activate
set frontmost of _window to true
set selected of _tab to true
do script "clear" in tab 1 of window 1
do script _command in tab 1 of window 1
end
end execInTerminalTab
on run argv
set _command to item 1 of argv
set _foundTab to false
set _expected_title to (item 2 of argv)
if length of argv is 2
tell application "Terminal"
repeat with w in windows
tell w
repeat with t in tabs
set _foundTab to true
set _window to w
set _tab to t
exit repeat
end repeat
end tell
if _foundTab then
exit repeat
end if
end repeat
end tell
if _foundTab then
execInTerminalTab(_command, _window, _tab)
else
execInNewTab(_expected_title, _command)
end if
end if
end run