The following is a rewrite of change gnome terminal title after some experimentation and exploration. Applicable to xterm*
, rxvt*
, GNOME Terminal, likely others.
problem
When I open a terminal window, the title is Terminal
. When I ssh
into another host, the title changes to me@somehost: mypath
. When I close the session, the window title is still me@somehost: mypath
.
first solution
Addresses the issue, not the cause, by changing the title back.
$ cat `which ctt` #!/bin/bash test $1 || set Terminal echo -ne "\e]0;$*\a"
No arguments sets the title to Terminal
. Otherwise the title is set to the arguments.
Links with more information:
https://tldp.org/HOWTO/Xterm-Title.html
and especially
https://tldp.org/HOWTO/Xterm-Title-3.html
Less helpful Stackexchange link
https://unix.stackexchange.com/questions/177572/how-to-rename-terminal-tab-title-in-gnome-terminal
perhaps better
The remote host has a case "$TERM"
in .bashrc
setting the prompt to one that will change the terminal title. My .bashrc
does not, either due to operator error, or perhaps a faulty gpg-agent
package install script clobbered it. Copy /etc/skel/.bashrc
to your $HOME
. If you already have a .bashrc
you want to keep, prepend the contents of /etc/skel/.bashrc
.
This /etc/skel/.bashrc
is found on Debian and Debian derived distributions. Your mileage may vary.
Here are the lines that set the title:
$ grep -A4 -B3 ]0 /etc/skel/.bashrc # 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
note
You can’t have your cake and eat it too. If you set your .bashrc
to change the title with every prompt, the title you set with the first solution will be overwritten by the next prompt, before you can see it.