-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterm2.zsh
46 lines (39 loc) · 1.23 KB
/
iterm2.zsh
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
# Usage:
# source iterm2.zsh
# from https://gist.github.com/wadey/1140259
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
echo -ne "\033]6;1;bg;blue;brightness;$3\a"
}
tab-red() { tab-color 255 0 0 }
tab-green() { tab-color 0 255 0 }
tab-blue() { tab-color 0 0 255 }
tab-reset() { echo -ne "\033]6;1;bg;*;default\a" }
function iterm2_tab_precmd() {
tab-reset
}
function iterm2_tab_preexec() {
if [[ "$1" =~ "^ssh " ]]; then
if [[ "$1" =~ "preprod" ]]; then
tab-color 160 160 255
elif [[ "$1" =~ "prod" ]]; then
tab-color 255 100 100
elif [[ "$1" =~ "dev" ]]; then
tab-color 160 255 160
else
tab-color 160 160 255
fi
elif [[ "$1" =~ "vagrant ssh" ]]; then
tab-color 160 255 160
#else
# tab-color 160 160 255
fi
}
autoload -U add-zsh-hook
add-zsh-hook precmd iterm2_tab_precmd
add-zsh-hook preexec iterm2_tab_preexec
fi