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?

false
  • 1,852
  • This might be of interest: https://askubuntu.com/questions/636944/how-to-change-the-title-of-the-current-terminal-tab-using-only-the-command-line – B.Tanner Mar 07 '19 at 08:49

3 Answers3

11

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

cmak.fr
  • 8,696
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

Abhi25t
  • 121
1

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
}
waltinator
  • 36,399