The basic screen commands:

ctrl-a c creates a new shell

ctrl-a n go to the next shell

ctrl-a p  go to the previous shell

ctrl-a " shows a list of all the shells.  Select a shell with the cursor keys & hit enter.

In the window list, , . move the highlighted window up or down the list.

ctrl-a ctrl-a toggles between 2 shells

ctrl-a k kill a shell.  Useful for a lot of programs that become zombies

ctrl-a H start/stop capturing to a file.  The file is named after the number of the screen shell.  Requires a keypress to clear the notification.


More advanced commands:

ctrl-a d detach the current shell, making it a daemon.  You can log out without ending it.

screen -r [daemon name] reattaches to a daemon & shows the terminal output

screen -ls shows the daemons


Splitting a screen:

The xterm scroll buffer is useless in split screen mode, but it can be useful if you're only using 11 rows.

ctrl-a shift-s splits the screen

ctrl-a ctrl-i toggle between panels.  Once in a different panel, use ctrl-a " to select a shell to show in it

ctrl-a shift-q unsplit the screen, keeping the current panel

ctrl-a shift-x unsplit the screen, keeping the other panel


Scrolling in screen:

Screen by default doesn't use the xterm scroll buffer, but has its own buffer which is intended for copying text.

ctrl-a ESC enters the copy mode

In copy mode, ? / n cause it to search for text the same as less & vi, but it doesn't show line numbers or wrap around.  g G cause it to go to the start & end.

cursor keys & pgup scroll back

ESC escapes from the copy mode.  Helas, this requires sending another keypress to clear the notification.

To erase the scroll buffer, you have to enter 2 commands with crtl-a : 

scrollback 0

scrollback 1000000

To make screen more intuitive, it must be forced to use the xterm scroll buffer by editing /etc/screenrc

This magic line should already be in /etc/screenrc & just needs to be uncommented:

termcapinfo xterm|xterms|xs|rxvt ti@:te@

The xterm scroll buffer is not swapped when changing shells.  You still have to go back to abusing the copy feature for that.  Lions used to jump around the screen program like a pro & screen's disabling of the xterm scroll buffer makes lions believe it was originally just needed on vt100's.


The /etc/screenrc file

Your biggest allies in this file are 

vbell off

Get rid of all the random flashing.

defscrollback 1000000

Create a useful scroll buffer.


Giving shells useful titles

The lion screen program has the hostname & directory of all its shells, but it doesn't do this by default.

The titles of the screens have to be customized.  In Linux, it's done by appending a kludge to print an escape sequence right before the command prompt.  It can't show the currently running program but it can show the prompt.  It takes some doing to delete all the other PS1 declarations & make sure this is the only one:

export PS1='`whoami`@`hostname`:`pwd`% '
# customize the screen title
case $TERM in
        # ESC k ESC \ tells screen to set its title
Read more »