Screen tomfoolery
I’ve been using GNU screen for a long time. Probably something like 15 years. But I’ve pretty much always used it in a fairly naive way, no custom configuration, and when working remotely I’ll typically log in to the “gateway” machine, run screen there, and wind up with 20-30 sessions sitting in it and eventually go nuts trying to figure out what exactly any given session actually is.
Which has motivated me to learn a bit more about what’s going on, and, admittedly, to cargo-cult a bit too.
So here’s my .screenrc as it stands now:
hardstatus alwayslastline
hardstatus string '%{= BW}[%H] %{= BW}%-Lw%{= RW}%50> %n%f* %t%{= BW}%+Lw%< %{= BW}% -=%c%{-}'
defscrollback 1000
vbell off
term xterm
The nifty bit is that “hardstatus string” line. What it does is give me a line at the bottom of the terminal which looks a bit like this:
[prod01au] 0* bash 1 sqsh 2 log 15:39
Except generally with a lot more “screens”.
In addition to this I have a few aliases of the form:
alias sqsh=screen -t sqsh sqsh -Usa -S`hostname`
to make it easy to fire off what I need with the right labels. Of course that ’sqsh’ example is grossly simplified, and for sqsh itself I actually use a wrapper script because the database names are not always the same as the hostnames, but anyway…
So now I make a point of running screen directly on each system I touch, which means that:
- I can see at the bottom-left exactly which host it is, whatever crappy prompt settings might be in place;
- I can see which “screens” are running what;
- I’ve always got a couple of useful things there, ready for next time, like a “tail -f” of the Sybase error log;
- I’m much more efficient.
All this is usually running in a tabbed terminal emulator (Apple’s Terminal.app at the moment, but in theory any will do), one tab per host. And it’s dead easy to pick these sessions up from anywhere, of course, which was the reason I was using screen in the first place.
Popularity: 19% [?]