Automatically set title on iTerm tabs

If like me you use iTerm for your terminal sessions, this is the tips to dynamically set the tab title.

As I’m using the bash shell, the tab title can be automatically set with the PROMPT_COMMAND variable. You can set this variable in /etc/profile or in your .bashrc

Mine is like this :

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}\007"'

The content of the variable is executed each time bash prints your prompt. Here echo is executed with the escape sequence to set the term title.

More informations

Some readings about this subject :

 
  • Pingback: » Set Terminal tab title in Mac OS X()

  • Marcus Aurelius

    Your blog’s font incorrectly changes single and double quotes to their complex UTF-8 equivalents. You should alter it immediately across the board to enable copy+pasting directly into UTF-8 compatible documents but still allow compilers and text editors to recognize normal single and double quotes.

  • Charles

    Hi! Thanks, I’ve added a pre tag around the command