Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My daily workflow includes me

  1. Launching iTerm2
  2. Creating 3 tabs
  3. Setting one tab each to red, orange and yellow
  4. Changing to a specific path in each tab

I would like to script this process; shell, applescript, etc. However, I cannot seem to find a hook that allows me to change the tab color. Is this possible? Here is a screen shot with an example of what I am trying to achieve.

iTerm tab setup

share|improve this question
Doesn't Set window title and tab chrome background color help? – peth Mar 22 '12 at 15:38
up vote 11 down vote accepted

That's possible and you should read iterm escape codes for details.


I tried to setup the color of the terminal when I do ssh (.ssh/config) and it worked but surprise, when I close the ssh session, it will not call the script again, in order to restore the title/color.

Added a feature request to auto-colored tabs - do not forget to star it, or add your comments (patches are also welcome!)

share|improve this answer
I write an ssh wrapper script in my ~/bin which makes the tab color changes (and other things like custom background with server names) and uses an EXIT trap to change them back. – Aaron Jun 27 '13 at 18:12
Aaron, would you mind sharing your script? – lfender6445 Feb 26 '15 at 22:19
You can also do that: function ssh { command ssh $@; # RESET BACK -> don't know how yet! help needed here } – David Krmpotic Mar 17 '15 at 14:01
Somehow I found out... I pasted it as another answer – David Krmpotic Mar 17 '15 at 14:18

To reset the tab color after exiting the ssh session use:

function ssh {
  command ssh $@
  echo -e "\033]6;1;bg;red;brightness;176\a"
  echo -e "\033]6;1;bg;green;brightness;181\a"
  echo -e "\033]6;1;bg;blue;brightness;175\a"
share|improve this answer

I added this function to my ~/.profile file:

function color {
    case $1 in
    echo -e "\033]6;1;bg;red;brightness;57\a"
    echo -e "\033]6;1;bg;green;brightness;197\a"
    echo -e "\033]6;1;bg;blue;brightness;77\a"
    echo -e "\033]6;1;bg;red;brightness;270\a"
    echo -e "\033]6;1;bg;green;brightness;60\a"
    echo -e "\033]6;1;bg;blue;brightness;83\a"
    echo -e "\033]6;1;bg;red;brightness;227\a"
    echo -e "\033]6;1;bg;green;brightness;143\a"
    echo -e "\033]6;1;bg;blue;brightness;10\a"

After adding this function you have to open a new terminal session. Now you can enter:

$ color green


$ color orange

to change the Tab color.

I use Photoshop to compose colors: Photoshop color picker

This color picker values can be converted to the following commands (Just insert the R -> red, G -> green, B -> blue values into the right line after "brightness;" to get a different color):

    echo -e "\033]6;1;bg;red;brightness;57\a"
    echo -e "\033]6;1;bg;green;brightness;197\a"
    echo -e "\033]6;1;bg;blue;brightness;77\a"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .