Ubuntu – How to change Gnome-Terminal title

command linegnome-terminaltitlebar

I have several instances of terminals running in my working environment, what I would like is to set a specific title for each one, in order to have a clear idea what purpose the specific terminal serves i.e. Apache, editing_ini, postgres etc…

Of course from the command line.

Best Answer

  • Alternatives:

    • There are other ways however, you can also issue

      gnome-terminal --title="SOME TITLE HERE"
      

      This might not give the desired effect since there is a big chance that your .bashrc overwrites that behaviour.

    • Bringing us to the last method, which I shamelessly ripped out of my .bashrc.

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

    As an extra reference, this is the particular line in my .bashrc

    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    

    You may also need to comment this code out in your ~/.bashrc

    case "$TERM" in
    xterm*|rxvt*)
        # JEFFYEE REMOVED because it makes commands to title() not work
        #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac