Mon, 07 Mar 2005

An Ode to screen

Just a listing of the many ways that screen is indispensable to my way of using my computer.

The biggest thing is, of course, the fact that screen is detachable. Start screen, start a program, detach screen while in the middle of doing something, log out, login later, reattach, program is just as I left it. This works at a distance, too. I can leave my home and go elsewhere (work, friend's house, etc.) and be able to ssh to my home computer, reattach screen, and pick up exactly where I left off.

Second only to detachability is screen's multiplexing capability. A screen session can contain many different windows, each running a different program. This allows me to have an entire workspace within screen. I can have an editor in one window, working on some source code; a shell in another window, where I might be doing trial runs of the program; a web browser in a third window, which could be looking at some documentation; and so on. My normal screen setup has 15 windows, which I use for various purposes.

I can specify what programs to run from screen's config file. So when I start screen, my default workspace is already seeded with all the programs I use regularly (text editor, IRC client, web browser, mail client, etc.). I use this capability just to start some programs that I never even interact with, for example SETI@Home. Running it within screen ensures that it's running at all times (I always have a screen session running) and only one instance is ever running (I do everything within one screen session).

I can attach to the same session multiple times. So my customary graphical workspace is three xterms, all attached to the same screen session. This gives me more visual real estate, while allowing me to be very flexible. The windows displayed by each of the xterms change depending on what I'm doing at the moment.

Screen understands several different character encodings. I run all of my programs in UTF-8 mode. When I'm attached to my local xterms, screen passes the UTF-8 characters straight through, because the xterms can handle it. On friends' computers, screen translates the UTF-8 into ISO-8859-1, showing all the characters it can and filling in question marks for those it can't. Likewise for my serial terminal, which uses a CP437 charset. (I'll admit that that last took some work on my part.)

I can also input most Unicode characters via screen's digraph support. Press the right escape characters, enter an RFC1345 digraph, and whatever program I'm currently using gets a UTF-8 character. (This also took a little work--I had to patch screen to get digraph support for non-ISO-8859-1 characters.)

Screen keeps a separate scrollback buffer for each window. I have it set to keep a very large number of lines, which has come in useful on several occasions, especially since you can search through the scrollback buffer. ("What was the exact output of that command?" ::search:: "Ah, that was it.")

I've used screen's monitoring capabilities a lot. It can watch a particular window and notify you when there's new activity ("Oh, something happened in that log file.") or when it's been silent for a time ("Oh, that long-running compile is done.")

Screen supports having a caption line across the bottom of the screen. I use it to give me an omnipresent clock, as well as showing me info on the current window. The capability also exists to run arbitrary programs and put their output in the caption. On my laptop, I do this with information on the current state of its battery.

Instances of screen can be password protected, to prevent others from getting at your programs. I find this feature useful when using screen in a semi-public area where I might need to leave the computer for a time.

There are some features that, while not mind-blowing, are just nice to have around. Normally, when the last program in a window exits the window closes. With zombie control, the window remains, and you can restart the program with a single keypress. Very useful for windows dedicated to particular programs.

While I don't use it regularly, screen's multiuser support has been useful on a couple of occasions. When doing some collaborative programming, I created a single, multiuser screen session, and all of us connected to it. It proved very useful for sharing information among the group of people. ("Just go over to window 7, where I'll show you how feature X works...")

There are, of course, plenty of other useful aspects to screen. These are just the ones that I rely on or have found myself relying on. I encourage anyone who uses a command line regularly to give screen a try.

For further information:


Phil! Gold