Skip to content

Instantly share code, notes, and snippets.

@gaocegege
Created May 18, 2015 14:57
Show Gist options
  • Save gaocegege/dc4ebcd1838ff58bf03d to your computer and use it in GitHub Desktop.
Save gaocegege/dc4ebcd1838ff58bf03d to your computer and use it in GitHub Desktop.
add the script into .zshrc, and u can change the color of tab. from http://kendsnyder.com/tab-colors-in-iterm2-v10/
# iterm coloring
function tab-color() {
if [[ $# == 1 ]]
then
# convert hex to decimal
hex=$1
if [[ ${hex:0:1} == "#" ]]
then
# strip leading hash sign
hex=${hex:1:6}
fi
if [[ ${#hex} == 3 ]]
then
# handle 3-letter hex codes
hex="${hex:0:1}${hex:0:1}${hex:1:1}${hex:1:1}${hex:2:1}${hex:2:1}"
fi
r=$(printf "%d" 0x${hex:0:2})
g=$(printf "%d" 0x${hex:2:2})
b=$(printf "%d" 0x${hex:4:2})
else
r=$1
g=$2
b=$3
fi
echo -ne "\033]6;1;bg;red;brightness;$r\a"
echo -ne "\033]6;1;bg;green;brightness;$g\a"
echo -ne "\033]6;1;bg;blue;brightness;$b\a"
}
function tab-red() { tab-color 203 111 111; }
function tab-green() { tab-color 6cc276; }
function tab-yellow() { tab-color "#e8e9ac"; }
function tab-blue() { tab-color 6f8ccc; }
function tab-purple() { tab-color a789d4; }
function tab-orange() { tab-color fbbc79; }
function tab-white() { tab-color fff; }
function tab-gray() { tab-color c3c3c3c; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment