When screen is called, it creates a single window with a shell; the pathname of the shell is taken from the environment symbol $SHELL; if this is not defined, "/bin/sh" is used. New windows can be created at any time by calling screen from within a previously created window. The program to be started in a newly created window and optional arguments to the program can be supplied when screen is invoked. For instance,
will create a window with a C-Shell and switch to that window. When the process associated with the currently displayed window terminates (e.g. ^D has been typed to a shell), screen switches to the previously displayed window; when no more windows are left, screen exits.
When "/etc/utmp" is writable by screen, an appropriate record is written to this file for each window and removed when the window is terminated.
The following commands are recognized by screen:
The -e option can be used to specify a different command character and a character which, when typed immediately after the command character, generates a literal command character. The defaults for these two characters are "C-a" and `a'. (Note that the function to switch to the previous window is actually the command character typed twice; for instance, when screen is called with the option "-e]x" (or "-e ]x"), this function becomes "]]").
The following initialization commands are recognized by screen:
escape xy
Set the command character to x and the character generating a literal command character to y (see the -e option above).
bell message
When a bell character is sent to a background window, screen displays a notification in the message line (see below). The notification message can be re-defined by means of the "bell" command; each occurrence of `%' in message is replaced by the number of the window to which a bell has been sent. The default message is
Bell in window %
An empty message can be supplied to the "bell" command to suppress output of a message line (bell "").
screen [n] [cmds args]
Establish a window. If an optional number n in the range 0..9 is given, the window number n is assigned to the newly created window (or, if this number is already in use, the next higher number). Note that n has a value of zero for the standard shell window created after ".screenrc" has been read. If a command is specified after "screen", this command (with the given arguments) is started in the window; if no command is given, a shell is created in the window. Thus, if your ".screenrc" contains the lines
# example for .screenrc: screen 1 screen 2 telnet foobar
screen creates a shell window (window #1), a window with a TELNET connection to the machine foobar (window #2), and, finally, a second shell window (the default window) which gets a window number of zero. When the initialization is completed, screen always switches to the default window, so window #0 is displayed when the above ".screenrc" is used.
chdir [directory]
Change the current directory of screen to the specified directory or, if called without an argument, to the home directory (the value of the environment symbol $HOME). All windows that are created by means of the "screen" command from within ".screenrc" or by means of "C-a c'' are running in the current directory; the current directory is initially the directory from which the shell command screen has been invoked. Hardcopy files are always written to the directory in which the current window has been created (that is, not in the current directory of the shell running in the window).
bind key [function | cmd args]
Bind a function to a key. By default, each function provided by screen is bound to one or more keys as indicated by the above table, e.g. the function to create a new window is bound to "C-c" and "c". The "bind" command can be used to redefine the key bindings and to define new bindings. The key argument is either a single character, a sequence of the form "^x" meaning "C-x", or an octal number specifying the ASCII code of the character. If no further argument is given, any previously established binding for this key is removed. The function argument can be one of the following keywords:
shell Create new window with a shell kill Kill the current window quit Kill all windows and terminate other Switch to previously displayed window next Switch to the next window prev Switch to the previous window redisplay Redisplay current window hardcopy Make hardcopy of current window termcap Write termcap entry to $HOME/.screen/.termcap suspend Suspend screen windows Display list of window info Print useful information in the message line xon Send Control-q xoff Send Control-s version Display the version select0 Switch to window #0 ... select9 Switch to window #9
In addition, a key can be bound such that a window is created running a different command than the shell when that key is pressed. In this case, the command optionally followed by arguments must be given instead of one of the above-listed keywords. For example, the commands
bind ' ' windows bind ^f telnet foobar bind 033 su
would bind the space key to the function that displays a list of windows (that is, the function usually invoked by "C-a C-w" or "C-a w" would also be available as "C-a space"), bind "C-f" to the function "create a window with a TELNET connection to foobar", and bind "escape" to the function that creates a window with a super-user shell.
can be used to display a message line.
When the `NF' capability is found in the termcap entry of the terminal on which screen has been started, flow control is turned off for the terminal. This enables the user to send XON and XOFF characters to the program running in a window (this is required by the emacs editor, for instance). The command line options -n and -f can be used to turn flow control off or on, respectively, independently of the `NF' capability.
Screen never writes in the last position of the screen, unless the boolean capability `LP' is found in the termcap entry of the terminal. Usually, screen cannot predict whether or not a particular terminal scrolls when a character is written in the last column of the last line; `LP' indicates that it is safe to write in this position. Note that the `LP' capability is independent of `am' (automatic margins); for certain terminals, such as the VT100, it is reasonable to set `am' as well as `LP' in the corresponding termcap entry (the VT100 does not move the cursor when a character is written in the last column of each line).
Screen puts into the environment of each process started in a newly created window the symbols "WINDOW=n" (where n is the number of the respective window), "TERM=screen", and a TERMCAP variable reflecting the capabilities of the virtual terminal emulated by screen. The actual set of capabilities supported by the virtual terminal depends on the capabilities supported by the physical terminal. If, for instance, the physical terminal does not support standout mode, screen does not put the `so' and `se' capabilities into the window's TERMCAP variable, accordingly. However, a minimum number of capabilities 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 overstrike).
Some capabilities are only put into the TERMCAP variable of the virtual terminal if they can be efficiently implemented by the physical terminal. For instance, `dl' (delete line) is only put into the TERMCAP variable if the terminal supports either delete line itself or scrolling regions. If screen is called with the -a option, all capabilities are put into the environment, even if screen must redraw parts of the display in order to implement a function.
The following is a list of control sequences recognized by screen. "(V)" and "(A)" indicate VT100-specific and ANSI-specific functions, respectively.
$(HOME)/.screenrc screen initialization commands
$(HOME)/.screen Directory created by screen
$(HOME)/.screen/tty Socket created by screen
hardcopy.[0-9] Screen images created by the hardcopy function
/etc/termcap Terminal capability data base
/etc/utmp Login records
/etc/ttys Terminal initialization data
If `LP' is not set but `am' is set, the last character in the last line is never written, and it is not correctly re-displayed when the screen is scrolled up or when a character is deleted in the last line.
The VT100 "wrap around with cursor addressing" bug is not compensated when screen is running on a VT100.
`AL,' `DL', and similar parameterized capabilities are not used if present.
`dm' (delete mode), `xn', and `xs' are not handled correctly (they are ignored).
Different character sets are not supported.
`ms' is not advertised in the termcap entry (in order to compensate a bug in curses(3X)).
Scrolling regions are only emulated if the physical terminal supports scrolling regions.
Screen does not make use of hardware tabs.
Screen must be installed as set-uid with owner root in order to be able to correctly change the owner of the tty device file for each window. Special permission may also be required to write the file "/etc/utmp".
Entries in "/etc/utmp" are not removed when screen is killed with SIGKILL.