How to customize the Screen status line

A busy Screen session becomes harder to navigate when the only visible prompt belongs to the shell inside the current window. A compact status line keeps the host name, active window, and clock visible while long-running shells stay attached or detached in the background.

Screen uses hardstatus for a terminal status area or a reserved display line, and caption for labels on split regions. Format strings use percent escapes such as %H for the host name, %w for the window list, %c for the time, %3n for the window number, and %t for the window title.

Keep the format short enough for narrow SSH terminals, especially when %w expands to several windows. Screen can query the window labels that feed %w, but the status line itself is a display surface, so the final proof is the attached terminal with the reserved line visible.

Steps to customize the Screen status line:

  1. Confirm the target Screen session name.
    $ screen -ls
    There is a screen on:
            12345.work      (Detached)
    1 Socket in /run/screen/S-user.

    The examples below target the session named work. Use the session name shown by screen -ls when yours is different.

  2. Open the Screen config file.
    $ vi ~/.screenrc

    Most user sessions read ~/.screenrc unless $SCREENRC or screen -c points to another file.

  3. Add a compact hardstatus line and split-region caption.
    hardstatus alwayslastline
    hardstatus string '%H | %w | %c'
    caption splitonly '%3n %t'

    hardstatus alwayslastline reserves the last display line even when the terminal has its own hardware status feature. caption splitonly keeps captions limited to split-region sessions.

  4. Reload the config into the running session.
    $ screen -S work -X source ~/.screenrc

    Attached clients should update after the file is sourced. If Screen shows a screenrc warning, fix that line and source the file again before relying on the display.

  5. Rename unclear windows so the status line carries useful labels.
    $ screen -S work -p 0 -X title logs

    The -p 0 option preselects window 0 before sending the title command.

  6. Verify the window label that will appear in the %w status escape.
    $ screen -S work -Q windows
    0 logs

    If the output still shows a generic title such as bash, rename the window before relying on the status line for navigation.

  7. Attach to the session and check the reserved status line.
    $ screen -r work
    screen-host | 0* logs |  7:20

    The status line appears at the bottom of the attached terminal, not as normal shell output. The asterisk marks the selected window in the %w window list.