How to use the Screen command prompt

A running Screen session often needs a one-off command without editing a screenrc file or sending a command from another shell. The colon prompt opens Screen's command reader inside the attached display, so session commands can list windows, change the current title, or test a setting against the session already on screen.

The default prompt key sequence is C-a :. The prompt accepts Screen command lines, not shell commands, so type command names such as windows or title admin without a leading shell prompt. The same command language is used by screenrc files and screen -X, but the interactive prompt runs from the selected window or display unless the command itself targets another object.

The prompt is modal and appears on Screen's message line. Use a read-only command such as windows first, then change one visible value such as the current window title when checking syntax in a shared or long-running session.

Steps to use the Screen command prompt:

  1. Attach to the Screen session that should receive the command.
    $ screen -r work

    Use the session name from screen -ls when more than one session exists.

  2. Open the Screen command prompt from inside the session.
    C-a :

    C-a is the default command character. Use the configured prefix when the session changed it. The colon prompt is Screen's command reader, so do not enter a shell $ prompt there.

  3. List the Screen windows from the prompt.
    windows
    0* sh

    Press Enter after the command. The windows output marks the current window with *.

  4. Open the command prompt again before changing a visible value.
    C-a :
  5. Change the current window title from the prompt.
    title admin

    The title command changes Screen's label for the current window. It does not rename the shell process running inside that window.

  6. Verify the title through the command prompt.
    windows
    0* admin

    The updated title in the windows output confirms that Screen accepted the command typed at the colon prompt for the current window.

  7. Repeat the last Screen message from the attached session when it disappears before you finish reading it.
    C-a m

    The default lastmsg binding replays the most recent Screen message line.