Sunday, August 26, 2007


Screen is an awesome UNIX utility that allows you to continue running commands on a remote system even after you have logged out! Magic! Here is a nice "screen for dummies" tutorial with some links to related sites at the bottom.

On the command line
  • screen (will spew some text and then give a prompt) start a screen session
  • screen -r reattach to screen session
  • screen -d detach an attached screen session (good for logging in after network cuts out)
  • Launch screen with an alias such as alias screen='TERM=screen screen' in .bashrc to avoid your backspaces getting mangled
  • There is a ~/.screenrc file with which you can customize screen
My .screenrc

# don't mangle backspaces
termcapinfo xtermc kD=\E[3~

# no startup message
startup_message off

# set shell that launches
shell /bin/bash

# lots of scrollback
defscrollback 10000

# ignore case when searching in copy mode
ignorecase on

# make it obvious we're within screen
hardstatus string "screen%n - %h"

# vim-style bindings
bind k focus up # cycle to the above split
bind j focus down # cycle to the below split
bind l next # cycle to the next split
bind h prev # cycle to the previous split
bind n split # create a new split
bind ^N split # create a new split
bind q remove # remove the split
bind + resize +3 # increase split three lines
bind - resize -3 # decrease split three lines
bind _ resize max # maximize current split
bind = resize = # make all splits equal size
bind g info # display info on the split
bind ^G info # display info on the split

# other (some defaults, just to remind myself they exist)
bind Q only # get rid of all other splits but the current one
bind M monitor # toggle monitoring of the current window
bind t title # enter a title for this shell
bind a other # go to most recently viewed other split
bind \' windowlist -b # go to window list
bind x kill # close the current shell
bind ^X kill # close the current shell
bind \\ quit # close all shells

No comments: