screen manager with VT100/ANSI terminal emulation


Start a new screen session

>_ screen

Start a new named screen session

>_ screen -S [session_name]

Start a new daemon and log the output to screenlog.x

>_ screen -dmLS [session_name] [command]

Show open screen sessions

>_ screen -ls

Reattach to an open screen

>_ screen -r [session_name]

Detach from inside a screen

>_ Ctrl + A, D

Kill the current screen session

>_ Ctrl + A, K

Kill a detached screen

>_ screen -X -S [session_name] quit


screen [ -options ] [ cmd [ args ] ] screen -r [[pid.]tty[.host]] screen -r sessionowner/[[pid.]tty[.host]]


In order to do a full VT100 emulation screen has to detect that a se‐ quence of characters in the input stream was generated by a keypress on the user's keyboard and insert the VT100 style escape sequence. Screen has a very flexible way of doing this by making it possible to map ar‐ bitrary commands on arbitrary sequences of characters. For standard VT100 emulation the command will always insert a string in the input buffer of the window (see also command stuff in the command table). Because the sequences generated by a keypress can change after a reat‐ tach from a different terminal type, it is possible to bind commands to the termcap name of the keys. Screen will insert the correct binding after each reattach. See the bindkey command for further details on the syntax and examples. Here is the table of the default key bindings. The fourth is what com‐ mand is executed if the keyboard is switched into application mode. ┌────────────────┬──────────────┬──────────┬──────────┐ │Key name │ Termcap name │ Command │ App mode │ ├────────────────┼──────────────┼──────────┼──────────┤ │Cursor up │ ku │ \033[A │ \033OA │ ├────────────────┼──────────────┼──────────┼──────────┤ │Cursor down │ kd │ \033[B │ \033OB │ ├────────────────┼──────────────┼──────────┼──────────┤ │Cursor right │ kr │ \033[C │ \033OC │ ├────────────────┼──────────────┼──────────┼──────────┤ │Cursor left │ kl │ \033[D │ \033OD │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 0 │ k0 │ \033[10~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 1 │ k1 │ \033OP │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 2 │ k2 │ \033OQ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 3 │ k3 │ \033OR │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 4 │ k4 │ \033OS │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 5 │ k5 │ \033[15~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 6 │ k6 │ \033[17~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 7 │ k7 │ \033[18~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 8 │ k8 │ \033[19~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 9 │ k9 │ \033[20~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 10 │ k; │ \033[21~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 11 │ F1 │ \033[23~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Function key 12 │ F2 │ \033[24~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Home │ kh │ \033[1~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │End │ kH │ \033[4~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Insert │ kI │ \033[2~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Delete │ kD │ \033[3~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Page up │ kP │ \033[5~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Page down │ kN │ \033[6~ │ │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 0 │ f0 │ 0 │ \033Op │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 1 │ f1 │ 1 │ \033Oq │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 2 │ f2 │ 2 │ \033Or │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 3 │ f3 │ 3 │ \033Os │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 4 │ f4 │ 4 │ \033Ot │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 5 │ f5 │ 5 │ \033Ou │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 6 │ f6 │ 6 │ \033Ov │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 7 │ f7 │ 7 │ \033Ow │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 8 │ f8 │ 8 │ \033Ox │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad 9 │ f9 │ 9 │ \033Oy │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad + │ f+ │ + │ \033Ok │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad - │ f- │ - │ \033Om │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad * │ f* │ * │ \033Oj │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad / │ f/ │ / │ \033Oo │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad = │ fq ├──────────┤ \033OX │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad . │ f. │ . │ \033On │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad , │ f, │ , │ \033Ol │ ├────────────────┼──────────────┼──────────┼──────────┤ │Keypad enter │ fe │ \015 │ \033OM │ └────────────────┴──────────────┴──────────┴──────────┘

TITLES (naming windows)

You can customize each window's name in the window display (viewed with the "windows" command (C-a w)) by setting it with one of the title com‐ mands. Normally the name displayed is the actual command name of the program created in the window. However, it is sometimes useful to dis‐ tinguish various programs of the same name or to change the name on- the-fly to reflect the current state of the window. The default name for all shell windows can be set with the "shelltitle" command in the .screenrc file, while all other windows are created with a "screen" command and thus can have their name set with the -t option. Interactively, there is the title-string escape-sequence (kname\) and the "title" command (C-a A). The former can be output from an application to control the window's name under software control, and the latter will prompt for a name when typed. You can also bind pre-defined names to keys with the "title" command to set things quickly without prompting. Changing title bythis escape sequence can be controlled by defdynamictitle and dynamictitle commands. Finally, screen has a shell-specific heuristic that is enabled by set‐ ting the window's name to "search|name" and arranging to have a null title escape-sequence output as a part of your prompt. The search por‐ tion specifies an end-of-prompt search string, while the name portion specifies the default shell name for the window. If the name ends in a `:' screen will add what it believes to be the current command running in the window to the end of the window's shell name (e.g. "name:cmd"). Otherwise the current command name supersedes the shell name while it is running. Here's how it works: you must modify your shell prompt to output a null title-escape-sequence (k\) as a part of your prompt. The last part of your prompt must be the same as the string you speci‐ fied for the search portion of the title. Once this is set up, screen will use the title-escape-sequence to clear the previous command name and get ready for the next command. Then, when a newline is received from the shell, a search is made for the end of the prompt. If found, it will grab the first word after the matched string and use it as the command name. If the command name begins with either '!', '%', or '^' screen will use the first word on the following line (if found) in preference to the just-found name. This helps csh users get better command names when using job control or history recall commands. Here's some .screenrc examples: screen -t top 2 nice top Adding this line to your .screenrc would start a nice-d version of the "top" command in window 2 named "top" rather than "nice". shelltitle '> |csh' screen 1 These commands would start a shell with the given shelltitle. The ti‐ tle specified is an auto-title that would expect the prompt and the typed command to look something like the following: /usr/joe/src/dir> trn (it looks after the '> ' for the command name). The window status would show the name "trn" while the command was running, and revert to "csh" upon completion. bind R screen -t '% |root:' su Having this command in your .screenrc would bind the key sequence "C-a R" to the "su" command and give it an auto-title name of "root:". For this auto-title to work, the screen could look something like this: % !em emacs file.c Here the user typed the csh history command "!em" which ran the previ‐ ously entered "emacs" command. The window status would show "root:emacs" during the execution of the command, and revert to simply "root:" at its completion. bind o title bind E title "" bind u title (unknown) The first binding doesn't have any arguments, so it would prompt you for a title. when you type "C-a o". The second binding would clear an auto-title's current setting (C-a E). The third binding would set the current window's title to "(unknown)" (C-a u). One thing to keep in mind when adding a null title-escape-sequence to your prompt is that some shells (like the csh) count all the non-con‐ trol characters as part of the prompt's length. If these invisible characters aren't a multiple of 8 then backspacing over a tab will re‐ sult in an incorrect display. One way to get around this is to use a prompt like this: set prompt='^[[0000m^[k^[\% ' The escape-sequence "[0000m" not only normalizes the character at‐ tributes, but all the zeros round the length of the invisible charac‐ ters up to 8. Bash users will probably want to echo the escape se‐ quence in the PROMPT_COMMAND: PROMPT_COMMAND='printf "\033k\033\134"' (I used "\134" to output a `\' because of a bug in bash v1.04).


Each window in a screen session emulates a VT100 terminal, with some extra functions added. The VT100 emulator is hard-coded, no other ter‐ minal types can be emulated. Usually screen tries to emulate as much of the VT100/ANSI standard as possible. But if your terminal lacks certain capabilities, the emula‐ tion may not be complete. In these cases screen has to tell the appli‐ cations that some of the features are missing. This is no problem on machines using termcap, because screen can use the $TERMCAP variable to customize the standard screen termcap. But if you do a rlogin on another machine or your machine supports only terminfo this method fails. Because of this, screen offers a way to deal with these cases. Here is how it works: When screen tries to figure out a terminal name for itself, it first looks for an entry named "screen.", where is the contents of your $TERM variable. If no such entry exists, screen tries "screen" (or "screen-w" if the terminal is wide (132 cols or more)). If even this entry cannot be found, "vt100" is used as a substitute. The idea is that if you have a terminal which doesn't support an impor‐ tant feature (e.g. delete char or clear to EOS) you can build a new termcap/terminfo entry for screen (named "screen.") in which this capability has been disabled. If this entry is installed on your machines you are able to do a rlogin and still keep the correct term‐ cap/terminfo entry. The terminal name is put in the $TERM variable of all new windows. Screen also sets the $TERMCAP variable reflecting the capabilities of the virtual terminal emulated. Notice that, however, on machines using the terminfo database this variable has no effect. Fur‐ thermore, the variable $WINDOW is set to the window number of each win‐ dow. The actual set of capabilities supported by the virtual terminal de‐ pends on the capabilities supported by the physical terminal. If, for instance, the physical terminal does not support underscore mode, screen does not put the `us' and `ue' capabilities into the window's $TERMCAP variable, accordingly. However, a minimum number of capabili‐ ties must be supported by a terminal in order to run screen; namely scrolling, clear screen, and direct cursor addressing (in addition, screen does not run on hardcopy terminals or on terminals that over- strike). Also, you can customize the $TERMCAP value used by screen by using the "termcap" .screenrc command, or by defining the variable $SCREENCAP prior to startup. When the is latter defined, its value will be copied verbatim into each window's $TERMCAP variable. This can either be the full terminal definition, or a filename where the terminal "screen" (and/or "screen-w") is defined. Note that screen honors the "terminfo" .screenrc command if the system uses the terminfo database rather than termcap. When the boolean `G0' capability is present in the termcap entry for the terminal on which screen has been called, the terminal emulation of screen supports multiple character sets. This allows an application to make use of, for instance, the VT100 graphics character set or national character sets. The following control functions from ISO 2022 are sup‐ ported: lock shift G0 (SI), lock shift G1 (SO), lock shift G2, lock shift G3, single shift G2, and single shift G3. When a virtual termi‐ nal is created or reset, the ASCII character set is designated as G0 through G3. When the `G0' capability is present, screen evaluates the capabilities `S0', `E0', and `C0' if present. `S0' is the sequence the terminal uses to enable and start the graphics character set rather than SI. `E0' is the corresponding replacement for SO. `C0' gives a character by character translation string that is used during semi- graphics mode. This string is built like the `acsc' terminfo capabil‐ ity. When the `po' and `pf' capabilities are present in the terminal's term‐ cap entry, applications running in a screen window can send output to the printer port of the terminal. This allows a user to have an appli‐ cation in one window sending output to a printer connected to the ter‐ minal, while all other windows are still active (the printer port is enabled and disabled again for each chunk of output). As a side-ef‐ fect, programs running in different windows can send output to the printer simultaneously. Data sent to the printer is not displayed in the window. The info command displays a line starting `PRIN' while the printer is active. Screen maintains a hardstatus line for every window. If a window gets selected, the display's hardstatus will be updated to match the win‐ dow's hardstatus line. If the display has no hardstatus the line will be displayed as a standard screen message. The hardstatus line can be changed with the ANSI Application Program Command (APC): "ESC_ESC\". As a convenience for xterm users the sequence "ESC]0..2;^G" is also accepted. Some capabilities are only put into the $TERMCAP variable of the vir‐ tual terminal if they can be efficiently implemented by the physical terminal. For instance, `dl' (delete line) is only put into the $TERM‐ CAP variable if the terminal supports either delete line itself or scrolling regions. Note that this may provoke confusion, when the ses‐ sion is reattached on a different terminal, as the value of $TERMCAP cannot be modified by parent processes. The "alternate screen" capability is not enabled by default. Set the altscreen .screenrc command to enable it. The following is a list of control sequences recognized by screen. "(V)" and "(A)" indicate VT100-specific and ANSI- or ISO-specific func‐ tions, respectively. ESC E Next Line ESC D Index ESC M Reverse Index ESC H Horizontal Tab Set ESC Z Send VT100 Identification String ESC 7 (V) Save Cursor and Attributes ESC 8 (V) Restore Cursor and Attributes ESC [s (A) Save Cursor and Attributes ESC [u (A) Restore Cursor and Attributes ESC c Reset to Initial State ESC g Visual Bell ESC Pn p Cursor Visibility (97801) Pn = 6 Invisible Pn = 7 Visible ESC = (V) Application Keypad Mode ESC > (V) Numeric Keypad Mode ESC # 8 (V) Fill Screen with E's ESC \ (A) String Terminator ESC ^ (A) Privacy Message String (Message Line) ESC ! Global Message String (Message Line) ESC k A.k.a. Definition String ESC P (A) Device Control String. Outputs a string di‐ rectly to the host terminal without inter‐ pretation. ESC _ (A) Application Program Command (Hardstatus) ESC ] 0 ; string ^G (A) Operating System Command (Hardstatus, xterm title hack) ESC ] 83 ; cmd ^G (A) Execute screen command. This only works if multi-user support is compiled into screen. The pseudo-user ":window:" is used to check the access control list. Use "addacl :win‐ dow: -rwx #?" to create a user with no rights and allow only the needed commands. Control-N (A) Lock Shift G1 (SO) Control-O (A) Lock Shift G0 (SI) ESC n (A) Lock Shift G2 ESC o (A) Lock Shift G3 ESC N (A) Single Shift G2 ESC O (A) Single Shift G3 ESC ( Pcs (A) Designate character set as G0 ESC ) Pcs (A) Designate character set as G1 ESC * Pcs (A) Designate character set as G2 ESC + Pcs (A) Designate character set as G3 ESC [ Pn ; Pn H Direct Cursor Addressing ESC [ Pn ; Pn f same as above ESC [ Pn J Erase in Display Pn = None or 0 From Cursor to End of Screen Pn = 1 From Beginning of Screen to Cursor Pn = 2 Entire Screen ESC [ Pn K Erase in Line Pn = None or 0 From Cursor to End of Line Pn = 1 From Beginning of Line to Cursor Pn = 2 Entire Line ESC [ Pn X Erase character ESC [ Pn A Cursor Up ESC [ Pn B Cursor Down ESC [ Pn C Cursor Right ESC [ Pn D Cursor Left ESC [ Pn E Cursor next line ESC [ Pn F Cursor previous line ESC [ Pn G Cursor horizontal position ESC [ Pn ` same as above ESC [ Pn d Cursor vertical position ESC [ Ps ;…; Ps m Select Graphic Rendition Ps = None or 0 Default Rendition Ps = 1 Bold Ps = 2 (A) Faint Ps = 3 (A) Standout Mode (ANSI: Itali‐ cized) Ps = 4 Underlined Ps = 5 Blinking Ps = 7 Negative Image Ps = 22 (A) Normal Intensity Ps = 23 (A) Standout Mode off (ANSI: Italicized off) Ps = 24 (A) Not Underlined Ps = 25 (A) Not Blinking Ps = 27 (A) Positive Image Ps = 30 (A) Foreground Black Ps = 31 (A) Foreground Red Ps = 32 (A) Foreground Green Ps = 33 (A) Foreground Yellow Ps = 34 (A) Foreground Blue Ps = 35 (A) Foreground Ma‐ genta Ps = 36 (A) Foreground Cyan Ps = 37 (A) Foreground White Ps = 39 (A) Foreground De‐ fault Ps = 40 (A) Background Black Ps = … … Ps = 49 (A) Background De‐ fault ESC [ Pn g Tab Clear Pn = None or 0 Clear Tab at Cur‐ rent Position Pn = 3 Clear All Tabs ESC [ Pn ; Pn r (V) Set Scrolling Region ESC [ Pn I (A) Horizontal Tab ESC [ Pn Z (A) Backward Tab ESC [ Pn L (A) Insert Line ESC [ Pn M (A) Delete Line ESC [ Pn @ (A) Insert Character ESC [ Pn P (A) Delete Character ESC [ Pn S Scroll Scrolling Region Up ESC [ Pn T Scroll Scrolling Region Down ESC [ Pn ^ same as above ESC [ Ps ;…; Ps h Set Mode ESC [ Ps ;…; Ps l Reset Mode Ps = 4 (A) Insert Mode Ps = 20 (A) Automatic Line‐ feed Mode Ps = 34 Normal Cursor Visibility Ps = ?1 (V) Application Cur‐ sor Keys Ps = ?3 (V) Change Terminal Width to 132 col‐ umns Ps = ?5 (V) Reverse Video Ps = ?6 (V) Origin Mode Ps = ?7 (V) Wrap Mode Ps = ?9 X10 mouse track‐ ing Ps = ?25 (V) Visible Cursor Ps = ?47 Alternate Screen (old xterm code) Ps = ?1000 (V) VT200 mouse tracking Ps = ?1047 Alternate Screen (new xterm code) Ps = ?1049 Alternate Screen (new xterm code) ESC [ 5 i (A) Start relay to printer (ANSI Media Copy) ESC [ 4 i (A) Stop relay to printer (ANSI Media Copy) ESC [ 8 ; Ph ; Pw t Resize the window to `Ph' lines and `Pw' columns (SunView special) ESC [ c Send VT100 Identification String ESC [ x Send Terminal Parameter Report ESC [ > c Send VT220 Secondary Device Attributes String ESC [ 6 n Send Cursor Position Report


The following table describes all terminal capabilities that are recog‐ nized by screen and are not in the termcap(5) manual. You can place these capabilities in your termcap entries (in `/etc/termcap') or use them with the commands `termcap', `terminfo' and `termcapinfo' in your screenrc files. It is often not possible to place these capabilities in the terminfo database. LP (bool) Terminal has VT100 style margins (`magic margins'). Note that this capability is obsolete because screen uses the standard 'xn' instead. Z0 (str) Change width to 132 columns. Z1 (str) Change width to 80 columns. WS (str) Resize display. This capability has the desired width and height as arguments. SunView(tm) example: '\E[8;%d;%dt'. NF (bool) Terminal doesn't need flow control. Send ^S and ^Q direct to the application. Same as 'flow off'. The opposite of this capability is 'nx'. G0 (bool) Terminal can deal with ISO 2022 font selection sequences. S0 (str) Switch charset 'G0' to the specified charset. Default is '\E(%.'. E0 (str) Switch charset 'G0' back to standard charset. Default is '\E(B'. C0 (str) Use the string as a conversion table for font '0'. See the 'ac' capability for more details. CS (str) Switch cursor-keys to application mode. CE (str) Switch cursor-keys back to normal mode. AN (bool) Turn on autonuke. See the 'autonuke' command for more de‐ tails. OL (num) Set the output buffer limit. See the 'obuflimit' command for more details. KJ (str) Set the encoding of the terminal. See the 'encoding' com‐ mand for valid encodings. AF (str) Change character foreground color in an ANSI conform way. This capability will almost always be set to '\E[3%dm' ('\E[3%p1%dm' on terminfo machines). AB (str) Same as 'AF', but change background color. AX (bool) Does understand ANSI set default fg/bg color (\E[39m / \E[49m). XC (str) Describe a translation of characters to strings depending on the current font. More details follow in the next sec‐ tion. XT (bool) Terminal understands special xterm sequences (OSC, mouse tracking). C8 (bool) Terminal needs bold to display high-intensity colors (e.g. Eterm). TF (bool) Add missing capabilities to the termcap/info entry. (Set by default).


Screen has a powerful mechanism to translate characters to arbitrary strings depending on the current font and terminal type. Use this fea‐ ture if you want to work with a common standard character set (say ISO8851-latin1) even on terminals that scatter the more unusual charac‐ ters over several national language font pages. Syntax: XC={,,} :=