-
Notifications
You must be signed in to change notification settings - Fork 0
/
iterm2-helper.sh
executable file
·42 lines (38 loc) · 1.07 KB
/
iterm2-helper.sh
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
function ttab() {
local cmd=""
local cdto="$PWD"
local args="$@"
local title=""
if [ -d "$1" ]; then
cdto=`cd "$1"; pwd`
args="${@:2}"
fi
if [[ "$args" == *" --title "* ]]; then
title=$(echo "$args" | sed -n 's/.* --title \([^ ]*\).*/\1/p')
args=$(echo "$args" | sed 's/ --title [^ ]*//')
fi
if [ -n "$args" ]; then
cmd="; $args"
osascript -i <<EOF
tell application "iTerm2"
tell current window
create tab with default profile
tell the current session
write text "cd \"$cdto\"$cmd"
if "$title" is not "" then
set name to "$title"
end if
end tell
end tell
end tell
EOF
else
open -a iTerm $cdto
fi
}
ttab "dsa && dcu --title Docker"
ttab "cd hcu-urban-model-builder-backend && npm run dev --title BackendServer"
ttab "cd hcu-urban-model-builder-backend --title BackendCLI"
ttab "cd hcu-urban-model-builder-client && ember s --title ClientServer"
ttab "cd hcu-urban-model-builder-client --title ClientCLI"
echo -e "\033];Docker CLI\007"