Screen

From Wikifications
Jump to: navigation, search

Basics

Control-a (C-a) is screen attention sequence and preceeds all screen commands. For example, to create a new screen window, type control-a, then c. To clarify even further: hold control, type a, release control, press c.

c         = new window
k         = kill current window
d         = detach from screen
?         = show online help

From outside of the screen session:

screen -R = reattach
screen -x = multi-attach

To set screen name at start time:

screen -S foo

To reattach to screen with given name:

screen -x foo

caption and hardstatus

I use the following with Terminal's color scheme set to green on black:

caption always "%{Mk}%?%-Lw%?%{km}[%n*%f %t]%?(%u)%?%{mk}%?%+Lw%? %{mk}"
hardstatus alwayslastline "%{kW}%H %{kB}|%{km} %l %=%{km}%c:%s %D %M/%d/%Y "

Navigation

"         = list window names, numbers, and flags
N         = show current window number
A         = set window name
'         = specify name or number to switch to
space     = next window
backspace = prev window
#         = goto window number #
w         = show window list in status bar
C-a       = switch to most recent window

Split Windows

S         = create split in current region
tab       = move to next region
X         = delete current region
Q         = delete all but current region

Monitoring

M         = toggle activity monitor notifications in status bar
_         = toggle INactivity monitor notification in status bar (e.g. for when something's done compiling)
m         = recall last message displayed in status bar
C-g       = toggle audio / visual bell
t         = show time / load average

Scrollback / copy mode movement keys

[       = enter copy mode
        h, j, k, l move the cursor line by line or column by column.
        0,  ^  and  $  move to the leftmost column, to the first or last non-
          whitespace character on the line.
        H, M and L move the cursor to the leftmost column of the top,  center
          or bottom line of the window.
        + and - positions one line up and down.
        G moves to the specified absolute line (default: end of buffer).
        | moves to the specified absolute column.
        w, b, e move the cursor word by word.
        B, E move the cursor WORD by WORD (as in vi).
        C-u  and  C-d  scroll  the display up/down by the specified amount of
          lines while preserving the cursor position. (Default: half  screen-
          full).
        C-b and C-f scroll the display up/down a full screen.
        g moves to the beginning of the buffer.
        % jumps to the specified percentage of the buffer.

Pasteboard

Paste the contents of the pasteboard

C-a ]

Read the /etc/passwd file into register p and paste it back out

C-a : readreg p /etc/passwd
C-a : paste p
Marking:
  The  copy range is specified by setting two marks. The text between
  these marks will be highlighted. Press
  space to set the first or second mark respectively.
  Y and y used to mark one whole line or to mark from start of line.
  W marks exactly one word.
Repeat count:
  Any of these commands can be prefixed with a repeat count number by
  pressing digits 0..9 which is taken as a repeat count.
  Example:  "C-a  C-[  H  10 j 5 Y" will copy lines 11 to 15 into the
  paste buffer.
Searching:
  / Vi-like search forward.
  ? Vi-like search backward.
  C-a s Emacs style incremental search forward.
  C-r Emacs style reverse i-search.
Specials:
  There are however some keys that act differently than  in  vi.   Vi
  does  not  allow one to yank rectangular blocks of text, but screen
  does. Press c or C to set the left or right margin  respectively.  If  no  repeat
  count is given, both default to the current cursor position.
  Example: Try this on a rather full text screen: "C-a [ M 20 l SPACE
  c 10 l 5 j C SPACE".
  This moves one to the middle line of the screen, moves in  20  col-
  umns  left,  marks the beginning of the paste buffer, sets the left
  column, moves 5 columns down, sets the right column, and then marks
  the end of the paste buffer. Now try:
  "C-a [ M 20 l SPACE 10 l 5 j SPACE"
  and notice the difference in the amount of text copied.
 J  joins lines. It toggles between 4 modes: lines separated by a new-
   line character (012), lines glued seamless, lines  separated  by  a
  single  whitespace  and  comma  separated  lines. Note that you can
  prepend the newline character with a carriage return character,  by
  issuing a "crlf on".
 v  is  for all the vi users with ":set numbers" - it toggles the left
  margin between column 9 and 1. Press
  a before the final space key to toggle in append mode. Thus the  con-
  tents  of the paste buffer will not be overwritten, but is appended
  to.
 A toggles in append mode and sets a (second) mark.
  > sets the (second) mark and writes the contents of the paste  buffer
  to the screen-exchange file (/tmp/screen-exchange per default) once
  copy-mode is finished.
  This example demonstrates how to dump the whole  scrollback  buffer
  to that file: "C-A [ g SPACE G $ >".
  C-g gives information about the current line and column.
 x  exchanges  the first mark and the current cursor position. You can
  use this to adjust an already placed mark.
 @ does nothing. Does not even exit copy mode.
  All keys not described here exit copy mode.

Commands

Commands can exist in .screenrc or can be entered interactively with C-a, :

send the 'whoami' command to all screen windows simultaneously (\015 is octal for carriage return)

at \# stuff "whoami\015"

back to Main Page