Wednesday, December 26, 2012

Anatomy of a .screenrc

Having talked about GNU Screen in most of my previous posts, I wanted to cover my .screenrc configuration file. The config file is relatively short and simple.
startup_message off
vbell off
vbellwait 0
defscrollback 8192
defflow off

hardstatus alwayslastline "%-w%{= BW}%50>%n %t%{-}%+w%<"

escape ^\\
idle 1800 lockscreen
I will now break it down:
startup_message off
No big surprise, this turns off the GNU Screen Welcome Message.
vbell off
vbellwait 0
Disable the visual bell flash and status line.
defscrollback 8192
The default number of lines of scrollback is 100, way way too low. Sometimes 8192 is too low for me, but this does affect memory usage.
defflow off
Turn off screen's flow control, always messes me up.
hardstatus alwayslastline "%-w%{= BW}%50>%n %t%{-}%+w%<"
Change the last line of the display to a status line containing a partial list of windows, centered around the window you are on. Do this in a color that I don't find completely awful. Highlight the window that is selected. You can get all fancy and put system information, time/data, etc. in the status line, but I am content with a boiled down list of my windows.
escape ^\\
This is the Holy Grail line that messes me up if it is missing. The default command character for Screen is Ctl-a. For those use to GNY Readline/Bash key bindings, Ctl-a brings you to the beginning of the line, I use this extensively. In my search for an appropriate alternate key, I tried many and finally settled on Ctl-\. This does still have the issue that the default binding for Ctl-\ is the Quit character in terminals. So if you do not have GNU Screen running and hit Ctl-\, you will likely kill your foreground process. This can be combated with 'stty quit undef' but often if you aren't in a screen session it is because you are on a console, or using a terminal on a machine that isn't your home, in other words the stty command isn't going to be in your startup files and you are going to kill your foreground process, hopefully it doesn't cause too big of a problem.
idle 1800 lockscreen
You don't want all of your shells sitting around unlocked when you run to lunch do you? Do you sometimes forget to send that lockscreen command on your own (C-\ C-x for me or C-a C-x by default), this will automatically lock the screen after 30 minutes.

1 comment:

  1. As a note, you can still send a Ctl-a to the shell with the default command key by using "Ctl-a a" but I always found that cumbersome and non-intuitive.

    ReplyDelete