Go to the previous, next section.

Window Settings

These commands control the way screen treats individual windows in a session. See section Virtual Terminal, for commands to control the terminal emulation itself.

Naming Windows (Titles)

You can customize each window's name in the window display (viewed with the windows command (see section Windows) by setting it with one of the title commands. Normally the name displayed is the actual command name of the program created in the window. However, it is sometimes useful to distinguish 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 (see section Shell). You can specify the name you want for a window with the `-t' option to the screen command when the window is created (see section Screen Command). To change the name after the window has been created you can use the title-string escape-sequence (ESC k name ESC \) 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 predefined names to keys with the title command to set things quickly without prompting.

Title Command

Command: title [windowtitle]

(C-a A)
Set the name of the current window to windowalias. If no name is specified, screen prompts for one.

Dynamic Titles

screen has a shell-specific heuristic that is enabled by setting 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 portion 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 specified 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 (ESC k ESC \) as a part of your prompt. The last part of your prompt must be the same as the string you specified 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 `!', `%', 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 more accurate titles when using job control or history recall commands.

Setting up your prompt for shell titles

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-control characters as part of the prompt's length. If these invisible characters aren't a multiple of 8 then backspacing over a tab will result in an incorrect display. One way to get around this is to use a prompt like this:

set prompt='<ESC>[0000m<ESC>k<ESC>\% '

The escape-sequence `<ESC>[0000m' not only normalizes the character attributes, but all the zeros round the length of the invisible characters up to 8.

Tcsh handles escape codes in the prompt more intelligently, so you can specify your prompt like this:

set prompt="%{\ek\e\\%}\% "

Bash users will probably want to echo the escape sequence in the PROMPT_COMMAND:

PROMPT_COMMAND='echo -n -e "\033k\033\134"'

(I used `\134' to output a `\' because of a bug in v1.04).

Setting up shell Titles in your `.screenrc'

Here are some .screenrc examples:

screen -t top 2 nice top

Adding this line to your .screenrc would start a niced version of the top command in window 2 name `top' rather than `nice'.

shelltitle '> |csh'
screen 1

This file would start a shell using the given shelltitle. The title 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 previously 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-titles current setting (C-a E). The third binding would set the current window's title to `(unknown)' (C-a u).


Command: autonuke state

Sets whether a clear screen sequence should nuke all the output that has not been written to the terminal. See section Obuflimit. This property is set per display, not per window.

Command: defautonuke state

Same as the autonuke command except that the default setting for new displays is also changed. Initial setting is off. Note that you can use the special AN terminal capability if you want to have a terminal type dependent setting.


Command: console [state]

Grabs or ungrabs the machines console output to a window. When the argument is omitted the current state is displayed. Note: Only the owner of `/dev/console' can grab the console output. This command is only available if the host supports the ioctl TIOCCONS.


Command: kill

(C-a k, C-a C-k)
Kill the current window.
If there is an exec command running (see section Exec) then it is killed. Otherwise the process (e.g. shell) running in the window receives a HANGUP condition, the window structure is removed and screen switches to the previously displayed window. When the last window is destroyed, screen exits.
Caution: emacs users may find themselves killing their emacs session when trying to delete the current line. For this reason, it is probably wise to use a different command character (see section Command Character) or rebind kill to another key sequence, such as C-a K (see section Key Binding).


Command: deflogin state

Same as the login command except that the default setting for new windows is changed. This defaults to `on' unless otherwise specified at compile time (see section Installation). Both commands are only present when screen has been compiled with utmp support.

Command: login [state]

(C-a L)
Adds or removes the entry in `/etc/utmp' for the current window. This controls whether or not the window is logged in. In addition to this toggle, it is convenient to have "log in" and "log out" keys. For instance, bind I login on and bind O login off will map these keys to be C-a I and C-a O (see section Key Binding).


Command: defmode mode

The mode of each newly allocated pseudo-tty is set to mode. mode is an octal number as used by chmod(1). Defaults to 0622 for windows which are logged in, 0600 for others (e.g. when -ln was specified for creation. See section Screen Command).


Command: activity message

When any activity occurs in a background window that is being monitored, screen displays a notification in the message line. The notification message can be redefined by means of the activity command. Each occurrence of `%' in message is replaced by the number of the window in which activity has occurred, and each occurrence of `~' is replaced by the definition for bell in your termcap (usually an audible bell). The default message is

'Activity in window %'

Note that monitoring is off for all windows by default, but can be altered by use of the monitor command (C-a M).

Command: defmonitor state

Same as the monitor command except that the default setting for new windows is changed. Initial setting is `off'.

Command: monitor [state]

(C-a M)
Toggles monitoring of the current window. When monitoring is turned on and the affected window is switched into the background, the activity notification message will be displayed in the status line at the first sign of output, and the window will also be marked with an `@' in the window-status display (see section Windows). Monitoring defaults to `off' for all windows.


Command: obuflimit [limit]

If the output buffer contains more bytes than the specified limit, no more data will be read from the windows. The default value is 256. If you have a fast display (like xterm), you can set it to some higher value. If no argument is specified, the current setting is displayed. This property is set per display, not per window.

Command: defobuflimit limit

Same as the obuflimit command except that the default setting for new displays is also changed. Initial setting is 256 bytes. Note that you can use the special OL terminal capability if you want to have a terminal type dependent limit.


Command: windows

(C-a w, C-a C-w)
Uses the message line to display a list of all the windows. Each window is listed by number with the name of the program running in the window (or its title); the current window is marked with a `*'; the previous window is marked with a `-'; all the windows that are logged in are marked with a `$' (see section Login); a background window that has received a bell is marked with a `!'; a background window that is being monitored and has had activity occur is marked with an `@' (see section Monitoring); a window which has output logging turned on is marked with `(L)'; windows occupied by other users are marked with `&'; windows in the zombie state are marked with `Z'. If this list is too long to fit on the terminal's status line only the portion around the current window is displayed.

Go to the previous, next section.