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
TmuxRelationalObject acts as the base container
connecting these relationships.
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 |
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.