4

In previous versions of Ubuntu, like 14.04, it was possible to set the title of each terminal tab via the menu: Terminal -> Set Title ...

In 18.04, there is still the entry Terminal with options like Set Character Encoding, but Set Title is missing.

So how can I set the title in newer versions?

1
9

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

1
  • Thx! Works nicely
    – false
    Mar 7 '19 at 9:09
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

0

I use xttitle (in the xttitle package):

update_title()
{
    [[ $TERM = xterm ]] || [[ $TERM = xterm-color ]]  && xttitle "[$$] ${USER}@${HOSTNAME}:$PWD"
}

cd()
{
    [[ -z "$*" ]] && builtin cd $HOME
    [[ -n "$*" ]] && builtin cd "$*"
    update_title
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.