4

This question already has an answer here:

How can I programmically set the gnome-terminal title? I've tried

gnome-terminal --title="bla"

but this opens a new terminal window while outputting

Xlib:  extension "RANDR" missing on display ":0.0".

marked as duplicate by Evan Carroll, Eric Carvalho, karel, Elder Geek, Fabby Feb 28 at 23:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

Got this to work

PROMPT_COMMAND='echo -ne "\033]0;g0\007"' 

If this did not change your terminal title you will first have to open ~/.bashrc. Find the line that says:

PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Comment out this line, by putting a # character in front of it:

# PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Now add this line (you may want to put it just after the commented-out line):

PROMPT_COMMAND='echo -ne "\033]0;Terminal title name change here\007"'

Replace Terminal title name change here with whatever you want to change the Terminal title to be, if anything.

0

gksu gedit /usr/share/applications/gnome-terminal.desktop

find Name=Terminal

change to Name=whatever you want

save restart

name changed

IS that what you wanted ?

Or another way without leaving the terminal

cd /usr/share/applications

sudo sed -i 's/Terminal/Your new name here/' gnome-terminal.desktop

to see the name change appear on the icon in launcher you must also restart unity

unity &> /dev/null & disown

for more info about unity restart read https://askubuntu.com/a/38597/71679

`

  • Wanted a way to do it without restarting the terminal window. – Kurru Jun 26 '12 at 0:17
  • ok is that what you wanted ? – damien Jun 27 '12 at 4:16
  • Got this to work PROMPT_COMMAND='echo -ne "\033]0;g0\007"' – Kurru Jun 27 '12 at 4:22
0

The gnome-terminal option --title is often overridden by your .bashrc file which updates your terminal (or tab) title as the prompt changes.

case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
esac

Other posts have recommended commenting out this logic in the .bashrc, but this disables all terminals from tracking the prompt, which is sometimes useful.

To add an optional control modify your .bashrc to add an environment variable which when set, skips tying your terminal (tab) title to the prompt:

if [ -z "$BASHRC_SKIPPS1" ]
then
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
fi

Now, to invoke a terminal with a static title use:

$ BASHRC_SKIPPS1=true gnome-terminal --title="static title"

and to open a new tab in an existing terminal with a static title use:

$ BASHRC_SKIPPS1=true gnome-terminal --title="static title" --tab

To open a terminal with the title tracking the prompt use:

$ gnome-terminal

or a terminal tab with the title tracking the prompt use:

$ gnome-terminal --tab

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