Pondering the mystery…

screen_ssh

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

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]%<"