How to rename terminal tab title in gnome-terminal?

Create a function in ~/.bashrc:

function set-title() {
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}

Then use your new command to set the terminal title. It works with spaces in the name too

set-title my new tab title

It is possible to subsequently use set-title again (original PS1 is preserved as ORIG).


The user title code was removed1 from gnome-terminal 3.14. To set the title, you could use an escape sequence:

printf "\e]2;YOUR TITLE GOES HERE\a"

or e.g. with bash:

PROMPT_COMMAND='echo -ne "\033]0;YOUR TITLE GOES HERE\007"'

1: see gnome bug 724110 and gnome bug 740188.


New versions of gnome-terminal just thrown away most helpful professional features. :-(

I have tried to setup and get an older version of gnome-terminal running and also compared alternatives.

If terminator is too exotic for you, the mate-terminal is a great option! It is a fork of gnome-terminal and just keeps all the good features:

  • you can open multiple tabs from the command line giving them different titles

    mate-terminal --tab -t "aaa" --tab -t "bbb" --tab -t "ccc"
    
  • you can set up a keyboard shortcut (I use Ctrl+Shift-i) to set a title