Windows & Regions
GNU Screen & Linux Job Control
Chapter 4 · Windows & Split Regions Inside a Session
So far every session has held a single shell. A session can hold many, each in its own window, and you can split your terminal to see several windows at once. This is screen's "multiplexing" side (Chapter 1): one SSH connection, many things going on.
Creating and Moving Between Windows
| Keys | What it does |
|---|---|
Ctrl-a c | Create a new window with a shell and switch to it |
Ctrl-a n / Ctrl-a p | Next / previous window |
Ctrl-a 0–9 | Jump straight to window 0–9 |
Ctrl-a Ctrl-a | Toggle back to the window you were in before |
Ctrl-a ' | Prompt for a window number or name to switch to |
Ctrl-a " | Show a list of all windows to pick from |
Ctrl-a w | Briefly show the window list on the message line |
Windows are numbered from 0. When you close one, its number becomes free and a new window may reuse it, so the numbers can end up with gaps.
Naming and Closing Windows
Window numbers are hard to remember. Ctrl-a A lets you type a title for the current window, which
then appears in the Ctrl-a " list and can be used with Ctrl-a '. To close a window,
exit its shell, or press Ctrl-a k and confirm. When the last window closes, the session ends
(Chapter 2).
Opening a Window From the Command Line
Typing screen inside a session doesn't start a second, nested session: screen notices it's
already running and opens a new window in the current session instead. That gives a quick way to open a window
that runs a particular command, with a title:
A window started this way closes when its command ends. Chapter 8 shows how to do the same thing from outside the session.
Splitting the Display Into Regions
| Keys | What it does |
|---|---|
Ctrl-a S | Split the current region horizontally (one above the other) |
Ctrl-a | | Split the current region vertically (side by side) |
Ctrl-a Tab | Move the input focus to the next region |
Ctrl-a X | Remove the current region |
Ctrl-a Q | Remove every region except the current one |
Ctrl-a Tab,
then either create a window there with Ctrl-a c or show an existing one with
Ctrl-a n, Ctrl-a ", or a number.
layout commands can save and restore an arrangement, if you want your splits back.
Watching Windows for Activity
When you have several windows, you don't want to keep flicking between them to see whether something happened. Screen can watch them for you:
Ctrl-a M— monitor the current window for activity: you'll get a message when new output appears there while you're elsewhere.Ctrl-a _— monitor for silence: you'll get a message when the window stops producing output for a while, useful to know a long job has finished or hung.
Hands-On Exercises
In one session, create three windows titled edit, logs and shell. Practise switching between them with Ctrl-a n, a number, Ctrl-a " and Ctrl-a '. Then close logs and open a new window: what number does it get, and why?
Build the layout in this chapter's diagram: an editor across the top, tail -f on a log bottom-left, and top bottom-right. Then detach, reattach, and describe what you see.
In one window, run sleep 30; echo done and turn on silence monitoring. Switch to another window and wait. What happens, and why might this be more useful than activity monitoring for a long-running job?
Chapter 4 Quick Reference
- A session holds windows; the display is divided into regions, each showing one window
Ctrl-a cnew window;n/pnext/previous;0–9jump;Ctrl-atoggle;'prompt;"list;wquick listCtrl-a Anames a window;Ctrl-a kkills it- Inside a session,
screen -t title commandopens a new window instead of a nested session Ctrl-a Shorizontal split,|vertical split,Tabnext region,Xremove region,Qkeep only current- New regions start empty; splits are usually lost on reattach (use
layoutto keep them) Ctrl-a Mmonitors for activity,Ctrl-a _for silence