-
Star
(150)
You must be signed in to star a gist -
Fork
(43)
You must be signed in to fork a gist
-
-
Save wadey/1140259 to your computer and use it in GitHub Desktop.
| # Usage: | |
| # source iterm2.zsh | |
| # 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" =~ "prod" ]]; then | |
| tab-color 255 160 160 | |
| else | |
| tab-color 160 255 160 | |
| fi | |
| 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 |
hi,
i'm a newbie, just try iterm2 few days. After source iterm2.zsh , how to use it ? do u have an example or README for newbie?
tks!
hi,
i'm a newbie, just try iterm2 few days. After source iterm2.zsh , how to use it ? do u have an example or README for newbie?
tks!
At least how I'm using it, I have added it under plugin directory: $ZSH_CUSTOM/plugins/iterm2/iterm2.plugin.zsh and in .zshrc I have set ZSH_CUSTOM=~/example/zsh-custom and added to the plugins=(... iterm2)
hi,
i'm a newbie, just try iterm2 few days. After source iterm2.zsh , how to use it ? do u have an example or README for newbie?
tks!At least how I'm using it, I have added it under plugin directory: $ZSH_CUSTOM/plugins/iterm2/iterm2.plugin.zsh and in .zshrc I have set ZSH_CUSTOM=~/example/zsh-custom and added to the plugins=(... iterm2)
nice!! it's working now, tks!!
@wadey do you know if there is a way to change the background as well?
Is it possible to only color the title bar or use darker color on the tab bar location
The possibilities are documented here: https://www.iterm2.com/documentation-escape-codes.html
How do I use this?
thanks for sharing this! nice job. If you put some comments to explain some lines, that would be great.
Thank you for the reference. I created a fork with an update to customize the color by server and added the option to customize the background.
https://gist.github.com/andremacola/12337455f5dc43a3aa348a5aebcacbcf

I updated this gist with the better version, using pre and post hooks!