How to set the title in Terminal

Solution 1:

This function is removed since gnome 3
But, the gnome 2 terminal has been forked as mate-terminal, it has the function you want.

sudo apt-get install mate-terminal


If you want to keep the gnome 3 terminal and agree to rename tabs from command line, you can try this:

1- Add a function 'set-title' to the .bashrc
2- Rename a terminal title with set-title The New Title Name

nano ~/.bashrc

##Add the following to the .bashrc file
function set-title() {
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}

Usage : set-title My Tab Title

Solution 2:

In Ubuntu 20.04

PS1=$PS1"\[\e]0;New_Terminal_Name\a\]"

\[ begin a sequence of non-printing characters

\e]0; is the char sequence for setting the terminal title. Bash identifies this sequence and set the tile with the following characters. Number 0 turns out to be the value to reference the title property.

New_Terminal_Name is the tile we gave

\a is the ASCII bell character, also in this case, it marks the end of the tile to read from Bash.

\] end a sequence of non-printing characters