I use GNU Screen a lot – as in basically all the time, and when I SSH somewhere I like to set the title of the screen I’m in, so I can easily keep track of loads of them.
To do this I’ve pulled together ideas and suggestions from a bunch of people to come up with a script which can be executed by SSH when it connects to a remote server.
You’ll need to edit
~/.ssh/config
and set something like this:
Host * LocalCommand /path/to/screen_ssh.sh $PPID %n PermitLocalCommand yes
This will set the screen title to the name of the machine you SSH’d to and do its best to chop off extraneous Top-Level-Domain information (i.e. if you ssh to foo.company.com the title will be “foo”).
You can download the script here: screen_ssh.sh
This is an example, if such a thing were needed:
If you want the blue line to appear at the bottom of your Screen sessions, add this to ~/.screenrc (all on one line):
hardstatus alwayslastline
"%{= bw} %{= bc}[%{-}%0c%{= bc}]%{-} [%-Lw%{= bW}%{+b}%50>%n%f* %t%{-b}%{= bw}%+Lw]%<"



Do you know how to use it on mac?
Pionnier: Unfortunately not, I don’t know how OSX’s ssh stuff works.
I needed to add “PermitLocalCommand yes” to /etc/ssh/ssh_config instead of /etc/ssh/sshd_config on Ubuntu. Works great now! :)
How did you do your ascii art on the screenshot ? Did you use some framework or just by hand ? ‘Cause it is really cool :)
kinji: that’s the output of:
toilet –gay mairukipa.tenshu.net
(a really horrible name for an app and its colourful option, but there it is)
Do you have a method that also works on web ssh clients ?
Thomas: don’t use web ssh clients :)
Nice. But when exiting the ssh session I would like the title to change back to the old (bash), or even better, the local host. Now it just keep the hostname until I ssh to a new machine. Any ideas?