forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminal
executable file
·45 lines (40 loc) · 920 Bytes
/
terminal
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
#!/bin/sh
ITERM_EXISTS=`osascript <<EOF
set doesExist to false
try
do shell script "osascript -e 'exists application \"iTerm\"'"
set doesExist to true
end try
return doesExist
EOF`
if [ $ITERM_EXISTS == "true" ]; then
osascript > /dev/null <<EOF
tell application "iTerm"
activate
try
tell the first terminal
launch session "Default Session"
tell the last session
write text "bash -c \"clear && $*\""
end tell
end tell
on error
tell (make new terminal)
launch session "Default Session"
tell the last session
write text "bash -c \"clear && $*\""
end tell
end tell
end try
end tell
EOF
else
osascript > /dev/null <<EOF
tell application "Terminal" to activate
delay 0.4
tell application "System Events" to keystroke "t" using command down
tell application "Terminal"
do script "bash -c \"clear && $*\"" in window 1
end tell
EOF
fi