Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

$ gnome-terminal --title=bla
Xlib:  extension "RANDR" missing on display ":0.0".
share|improve this question

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer

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
share|improve this answer

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 http://askubuntu.com/a/38597/71679

`

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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