Architecture¶
libtmux is a typed
abstraction layer for tmux. It builds upon tmux’s concept of targets
(-t) to direct commands against individual sessions, windows, and panes,
and FORMATS — template variables tmux exposes to describe object
properties.
Object Hierarchy¶
libtmux mirrors tmux’s object hierarchy as a typed Python ORM:
Server
├── Session
│ └── Window
│ └── Pane
└── Client (attached view)
Object |
Child |
Parent |
|---|---|---|
None |
||
None |
||
None |
TmuxRelationalObject acts as the base container
connecting these relationships.
Client is a view, not part of the ownership chain:
each attached terminal points at a Session/Window/Pane it is currently
displaying, but is not owned by them. See Clients for the view-
vs-identity distinction.
Internal Identifiers¶
tmux assigns unique IDs to sessions, windows, and panes. libtmux uses
these — via TmuxMappingObject — to track objects
reliably across state refreshes.
Core Objects¶
Each level wraps tmux commands and format queries:
Data Flow¶
User creates a
Server(connects to a running tmux server)Queries use tmux format strings (
libtmux.constants) to fetch stateResults are parsed into typed Python objects
Mutations dispatch tmux commands via the
cmd()methodObjects refresh state from tmux on demand
Module Map¶
Module |
Role |
|---|---|
|
Server connection and session management |
|
Session operations |
|
Window operations and pane management |
|
Pane I/O and capture |
|
Attached-client view and live-attachment lookup |
Base classes, command execution |
|
|
Modern dataclass-based query interface |
Format string constants |
|
tmux option get/set |
|
tmux hook management |
|
Exception hierarchy |
Naming Conventions¶
tmux commands use dashes (new-window). libtmux replaces these with
underscores (new_window) to follow Python naming conventions.