Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change gnome-terminal title in Ubuntu 10

I've tried setting my PROMPT_COMMAND variable:

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

but something changes my tab (or the whole terminal title) to 'user@hostname:/current/path', thus

PROMPT_COMMAND='echo -ne "\033]0;"myWindowTitle"\007" && sleep 3'

changes title for 3 second only :)

like image 939
installero Avatar asked Oct 14 '10 10:10

installero


People also ask

How do I change GNOME Terminal name?

The Bash escape sequence to set the terminal title looks like this: \[\e]2;new title\a\] , and to apply this title to your terminal window, all you have to do is modify its "Prompt String 1", or PS1 variable, by adding this "set title" escape sequence after your current Prompt String 1, like this: PS1="${PS1}\[\e]2;new ...

What is the name of GNOME Terminal?

GNOME Terminal ( gnome-terminal from the command line or GNOME's Alt-F2 launcher) emulates the xterm terminal emulator and provides some of the same features.

Can you rename terminal tabs?

Naming Your Terminal tabs Given that we might be using a number of terminal sessions with a number of different processes or parameters, it's useful to rename the tabs to something helpful. You can do this from the context menu, which you can open by right-clicking on the tab.


3 Answers

PROMPT_COMMAND is issued before a prompt is set based on the PS1 variable. Probably you have some character sequence in PS1 which sets your windows title. You may invoke unset PS1 or set it to some other value:

export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

Alternatively you can set window title in your PS1 variable:

export PS1='\[\e]0;myWindowTitle\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$'
like image 149
Paweł Nadolski Avatar answered Oct 16 '22 23:10

Paweł Nadolski


In Ubuntu the .bashrc file has some code that adds text to the PS1 variable. This extra text changes the title after you set it with the --title option. Just comment it.

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac
like image 31
givanse Avatar answered Oct 17 '22 00:10

givanse


Rather than do:

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

Try using a variable and setting this in your .bashrc:

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

Then you can simply do this to change the window title at the prompt by:

WT="my new window title"

If you like, you can include the path in the window title in your .bashrc:

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

BTW, I don't think you need to "export" PS1.

like image 37
justingordon Avatar answered Oct 16 '22 23:10

justingordon