Windows and Splits
This chapter delivers two ways of having more than one thing in front of you: windows, several full terminals inside one session that you switch between, and regions (Screen's name for splits), several windows visible at once in one terminal. Windows are the everyday tool. Splits are for watching two things at the same time.
Windows: one at a time, all of them yours
A session starts with one window, number 0. The working keys:
| Keys | What happens |
|---|---|
| Ctrl-A c | Create a new window with a fresh shell |
| Ctrl-A n | Next window |
| Ctrl-A p | Previous window |
| Ctrl-A 0 … 9 | Jump straight to window by number |
| Ctrl-A " | A list of windows; arrow keys and Enter to choose |
| Ctrl-A A | Rename the current window |
| Ctrl-A k | Kill the current window (asks first) |
| Ctrl-A w | A brief list of windows, shown in the message line |
Each window runs its own program and
keeps its own scrollback. A common
arrangement: window 0 an editor, window
1 a shell for running what the editor
is editing, window 2 a tail -f on a
log. The names matter more than the
numbers once a session grows — rename
as you go, with Ctrl-A A, and the
window list becomes a table of contents
of what you were doing.
Programs that demand the whole screen —
editors, pagers, top — live happily
in windows, because each window is a
whole terminal as far as the program
can tell. When you switch away, Screen
keeps redrawing it; when you come back,
it is current.
Creating windows without touching the
keyboard is also possible, and the lab
uses it to build its demonstration
session (transcript
screen-lab/transcripts/t03-windows-and-hardcopy.txt):
screen -S demo -X screen -t logs 1
screen -S demo -X screen -t edit 2
The -X flag sends a Screen command
into a running session from outside —
here, "open a window titled logs at
number 1" — and the same message
mechanism can select windows, rename
them, and most other things the prefix
keys do.
Splits: regions
A region is a slice of your
terminal showing one window. Split the
current region horizontally with
Ctrl-A S and a second region opens
below — empty at first, showing nothing
until you choose a window for it with
the usual switching keys while it has
focus. Ctrl-A Tab moves focus
between regions; Ctrl-A X closes
the focused region; Ctrl-A Q closes
all the others and gives the focused
one the whole screen back. Ctrl-A |
splits vertically on 4.x builds, giving
side-by-side regions; the lab exercised
the horizontal split live (transcript
t02) and takes the vertical key from
the manual — a split is a redraw, and
a redraw is the one thing a text
transcript cannot flatten into proof,
so criteria.md files it honestly.
Two honest warnings about regions. First, they are a property of your client, not of the session: detach, and the arrangement is gone; reattach and you build it again. Several clients attached to one session (chapter 9) each keep their own regions. Second, regions shrink fast: a terminal split three ways leaves each pane too small for serious work, and two is the practical limit for most people most of the time — an editor beside the log it is reacting to, a shell beside the monitor watching it.
The status line
With several windows, it pays to see
the list without asking. A hardstatus
line — a status bar Screen draws at
the bottom of your terminal — can show
every window's number and title, with
the current one highlighted. Chapter 8
builds one in .screenrc. The real
line drawn by the lab's configured
session (transcript t05) is:
tuned: 0 editor 1 shell 2* logs
— session name first, then the windows, the asterisk marking the one on show.
Screen also uses a one-line message
area for its own remarks ([detached
...], the window list from Ctrl-A w,
prompts when a command needs to ask
something). Knowing the difference
keeps the display calm: the hardstatus
is yours and permanent, the message
line is Screen's and momentary.
Check
In one session, create three windows and name them. Ctrl-A " lists them with the titles you gave; Ctrl-A 2 takes you straight to the third. The lab's hardcopy capture in transcript t03 shows all three windows existing in one session, with their titles, exactly as the commands above created them — verified without a human at the keys.