Created
August 27, 2011 22:45
-
-
Save 20after4/1175961 to your computer and use it in GitHub Desktop.
.bash_profile for iTerm2 tabs colored by tty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "iTerm.app" == "$TERM_PROGRAM" ] ; then | |
# set up an array of RGB values | |
tabcolors[0]="244,0,200" | |
tabcolors[1]="0,200,244" | |
tabcolors[2]="68,250,132" | |
tabcolors[3]="250,68,132" | |
tabcolors[4]="250,132,68" | |
tabcolors[5]="220,200,100" | |
TTYNUM=`ps -p $$ -o tty= | cut -c 5,6,7` | |
# get the color at index ($TTY MOD $ARRAY_LENGTH) | |
tci=`expr $TTYNUM % ${#tabcolors[*]}` | |
TABCOLOR="${tabcolors[$tci]}" | |
# split the r,g,b values into RGB array | |
OIFS=$IFS | |
set -- "$TABCOLOR" | |
IFS=","; declare -a RGB=($*) | |
IFS=$OIFS | |
# output proprietary ansi codes for the iterm tab color | |
echo -e "\033]6;1;bg;red;brightness;${RGB[0]}\a\c" | |
echo -e "\033]6;1;bg;green;brightness;${RGB[1]}\a\c" | |
echo -e "\033]6;1;bg;blue;brightness;${RGB[2]}\a\c" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment