Server, session, window, pane
libtmux models tmux’s server, session, window, and pane objects:
Server├── Session│ └── Window│ └── Pane└── Client (attached view)A Server contains sessions. Each Session contains links to windows, and each
Window contains panes. Commands run inside a Pane, where you send input and
capture output. A window can be linked to more than one session.
Stable identity, not name or index¶
tmux assigns a unique ID to each session, window, and pane at creation. The ID remains stable for that object’s lifetime even if its name or index changes:
| Object | ID prefix | Example |
|---|---|---|
| Session¶ | $ | $13 |
| Window¶ | @ | @3243 |
| Pane¶ | % | %5433 |
| Server¶ | - | identified by socket name or path instead |
Use stable IDs to identify the same tmux object across reads. Names and indexes can change while a program is running.
Read the hierarchy:
// A snapshot reads sessions, windows, and panes in one pass; the relations// below resolve against it without another tmux command.let snapshot = try await server.snapshot()for session in snapshot.sessions { print(session.name) for window in snapshot.windows(of: session) { print(" ", window.name) for pane in snapshot.panes(of: window) { print(" ", pane.id, pane.currentCommand) } }}Client: a view, not a child¶
A Client represents a terminal attached to a session. Several clients can view
the same server, and each can switch sessions or windows independently. Client
fields describe the view at the time of the read.
A control-mode connection is also a client. It appears in
list-clients, counts toward session_attached, and affects
attachment-dependent behavior such as destroy-unattached. Closing the last
attached client can therefore destroy a session configured with that option.