Screen Gotchas

If you’ve used *nix-based operating systems for any length of time, you’ve probably come across the gem that is screen. While Gnome and KDE both provide tabbed terminals that largely supplant the needs of screen, the latter is perfect for maintaining multiple sessions on a remote–or not so remote–host. Screen does have a few “gotchas” that can surface and they’re hugely annoying if you’re not familiar with some of its more esoteric shortcuts.

The winter months can spell disaster for faster touch typists unaccustomed to cold fingers. Further, cold fingers can stumble into shortcut keys or key combinations that generate unusual behavior. One such instance involved screen’s xoff command; for the longest time, I assumed that my terminal was freezing as I couldn’t use the usual commands (^a n or ^a p) to move between my terminal sessions. Even the detach (^a d) shortcut wasn’t working! Once I found out the cause, I also discovered why this behavior only seems to affect certain terminals (especially PuTTY under Windows).

As it turns out, the screen command to send xoff (or control-s) to the terminal is unfortunately close to the screen base command, making it especially easy to slip up and press during colder months of the year. ^a s, denoted as C-a s in screen syntax sends an xoff to your terminal, and depending on the terminal settings you may notice what can only described as an unfortunate freeze. The obvious solution is to simply kill the terminal, restart it, login, and resume your previous screen session (screen -rd, optionally including screen’s process ID if you have multiple sessions active), but the obvious solution isn’t always the best solution. Fortunately, control-q will send xon to the terminal, restoring it to its previous state; to send a control-q in screen, simply type ^a q (C-a q) and the terminal session will resume its previous behavior.

Since I don’t bother much with the quirks of terminals particularly often, I’ve never had much use for xoff/xon. Not surprisingly, this behavior was rather unexpected, particularly since I wasn’t aware screen actually sent certain control codes to the terminal (aside from the obvious, of course). The humorous thing? I’ve been using screen for at least 5 or 6 years!

Other handy screen shortcuts (these are the ones I use most frequently and find useful; there are many others):

C-a " List all windows available in this session
C-a p Previous window
C-a n Next window
C-a d Detach screen (leaves all shells/apps running)
C-a c Create a new window (shell) in this session
C-a [ Copy mode, useful for scrolling back inside screen’s buffer; press ESC to exit
C-a Q Removes the split screen; useful if you’ve accidentally pressed C-a S

Leave a comment

Valid tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>