Take advantage of screen

2015-10-04 20:53

Some advantages of using screen:

  • Multiplexing, Using multiple windows (running/debugging, editor, version control, etc)
  • De-coupled from desktop window manager
  • Persistence, possible to detach/reattach sessions
  • Easily accessible remotely via SSH
  • Able to share screen sessions with others over SSH

Here's a short list of some useful keyboard shortcuts for screen to release some of its power.

Key             Action                                      Notes
Ctrl+a c        new window
Ctrl+a n        next window
Ctrl+a p        previous window
Ctrl+a "        select window from list
Ctrl+a Ctrl+a   previous window viewed
Ctrl+a A        Re-name window

Ctrl+a S        split terminal horizontally into regions    Ctrl+a c to create new window there
Ctrl+a |        split terminal vertically into regions      Requires screen >= 4.1 
Ctrl+a :resize  resize region
Ctrl+a :fit     fit screen size to new terminal size        Ctrl+a F is the same. Do after resizing xterm
Ctrl+a :remove  remove region                               Ctrl+a X is the same
Ctrl+a tab      Move to next region

Ctrl+a d        detach screen from terminal                 Start screen with -r option to reattach
Ctrl+a A        set window title
Ctrl+a x        lock session                                Enter user password to unlock
Ctrl+a esc      enter scrollback/copy mode                  Ctrl+a [ is the same., esc to escape back to 
                                                            normal mode or enter/space to mark text to copy 
Ctrl+a ]        paste buffer                                Supports pasting between windows
Ctrl+a >        write paste buffer to file                  useful for copying between screens
Ctrl+a <        read paste buffer from file                 useful for pasting between screens

Ctrl+a ?        show key bindings/command names             Note unbound commands only in man page
Ctrl+a :        goto screen command prompt                  up shows last command entered

Note: screen has its own scrollback buffer seperate from your terminal emulator such as xterm or rxvt. It is accessible through the copy/scrollback mode reachable by ctrl+a esc. In this mode a vi-like editor is active. Use esc escape back to normal mode.