Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

API reference

Browse the Python types and operations for working with tmux. Start with the core objects below, or search for a type or member.

Server 1 type, 2 functions and constants
Server class 98 members

tmux(1) Server [server_manual].

Wrap fetch_objs : treat a not-yet-started server as empty.

Return True if the error indicates the tmux server is not running.

Session 1 type, 2 functions and constants
Session class 248 members

tmux(1) Session [session_manual].

SessionDict constant

Raise exception session name invalid, modeled after tmux function.

Window 2 types, 3 functions and constants
Window class 254 members

tmux(1) Window [window_manual].

WindowDirection class 2 members

Used for adjustment in Session.new_window() .

WindowDict constant
Pane 2 types, 2 functions and constants
Pane class 257 members

tmux(1) Pane [pane_manual].

PaneDirection class 4 members

Used for adjustment in Pane.split() .

PaneDict constant
Client 1 type
Client class 186 members

tmux(1) Client [client_manual].

Hooks 1 type, 3 functions and constants
HooksMixin class 12 members

Mixin for manager scoped hooks in tmux.

HookDict constant
HookValues constant
Options 2 types
OptionScope class 4 members

Scope used with set-option and show-option(s) commands.

OptionsMixin class 12 members

Mixin for managing tmux options based on scope.

Options — Functions 6 functions and constants
convert_value function

Convert raw option strings to python types.

Recursively convert values to python types via convert_value .

Explode flat, naive options dict's option arrays.

Explode arrayed option's complex values.

Raise exception if error in option command found.

Process subprocess.stdout options or hook output to flat, naive, untyped dict.

Options — Constants and variables 11 functions and constants
Layout and geometry 1 type, 1 function or constant

Used for adjustment in resize_window, resize_pane.

Environment 1 type
EnvironmentMixin class 8 members

Mixin for manager session and server level environment variables in tmux.

Versions 13 functions and constants
__version__ constant

Return a synthetic version string when tmux lacks -V.

Return libtmux version is a PEP386 compliant format.

get_version function

Return tmux version.

Return the tmux version string verbatim, preserving letter suffixes.

Return True if tmux version greater than minimum.

Return True if tmux version greater or equal to minimum.

Return True if tmux version less than minimum.

Return True if tmux version less or equal to minimum.

Return True if tmux meets version requirement. Version >= 3.2a.

has_version function

Return True if tmux version installed.

Commands 3 types
CmdProtocol class 1 member

Command protocol for tmux command.

CmdMixin class 1 member

Command mixin for tmux command.

tmux_cmd class 1 member

Run any tmux(1) command through subprocess.

Formats 21 functions and constants
FIELD_VERSION constant

Minimum tmux version that registers each format token.

OutputRaw constant
OutputsRaw constant
PANE_FORMATS constant

Format-token scopes a given tmux list-* subcommand can resolve.

Return True if tmux failed because the -t target does not exist.

Convert a tmux version string into a comparable LooseVersion.

_token_scope function

Resolve a format token's scope from its name.

fetch_obj function

Fetch the single list-* row whose obj_key equals obj_id.

fetch_objs function

Fetch a listing of raw data from a tmux command.

Return field names and tmux format string filtered by scope and version.

parse_output function

Parse a tmux -F line into a dict keyed by Obj field name.

Queries 1 function or constant

Return the raw tmux -V version token, letter suffix intact.

Errors 18 types, 2 functions and constants

Internal signal: this tmux predates the -V flag (pre-1.7).

LibTmuxException exception 2 members

Base Exception for libtmux Errors.

DeprecatedError exception 2 members

Raised when a deprecated function, method, or parameter is used.

TmuxCommandNotFound exception 2 members

Application binary for tmux not found.

NotInsideTmux exception 2 members

Raised when the process is not running inside a tmux pane.

ObjectDoesNotExist exception 2 members

A lookup expected one object and matched none.

MultipleObjectsReturned exception 2 members

A lookup expected one object and matched several.

TmuxObjectDoesNotExist class 2 members

tmux has no object with the id that was asked for.

VersionTooLow exception 2 members

Raised if tmux below the minimum version to use libtmux.

OptionError exception 2 members

Root error for any error involving invalid, ambiguous or bad options.

UnknownOption exception 2 members

Option unknown to tmux show-option(s) or show-window-option(s).

UnknownColorOption class 2 members

Unknown color option.

InvalidOption exception 2 members

Option invalid to tmux.

AmbiguousOption exception 2 members

Option that could potentially match more than one.

WaitTimeout exception 2 members

Function timed out without meeting condition.

VariableUnpackingError exception 2 members

Error unpacking variable.

If adjustment_direction is set, adjustment must be set.

RequiresDigitOrPercentage exception 2 members

Requires digit (int or str digit) or a percentage.

_format_query function

Render a QueryList.get lookup back as key=value text.

Raise LibTmuxException tagged with the tmux subcommand on stderr.

Errors — Session 2 types
TmuxSessionExists exception 2 members

Session does not exist in the server.

BadSessionName exception 2 members

Disallowed session name for tmux (empty, contains periods or colons).

Errors — Window 5 types
WindowError exception 2 members

Any type of window related error.

MultipleActiveWindows exception 2 members

Multiple active windows.

NoActiveWindow exception 2 members

No active window found.

NoWindowsExist exception 2 members

No windows exist for object.

ValueError for libtmux.Window.resize_window.

Errors — Pane 3 types
PaneError exception 2 members

Any type of pane related error.

PaneNotFound exception 2 members

Pane not found.

Testing utilities 13 functions and constants
USING_ZSH constant

Kill the tmux daemon on socket_name and unlink the socket file.

clear_env function

Clear out any unnecessary environment variables that could interrupt tests.

config_file function

Return fixture for .tmux.conf configuration.

control_mode function

Return ControlMode context manager factory.

home_path function

Temporary /home/ path.

Return default username to set for user_path fixture.

server function

Return new, temporary libtmux.Server .

session function

Return new, temporary libtmux.Session .

Return default session creation parameters.

TestServer function

Create a temporary tmux server that cleans up after itself.

user_path function

Ensure and return temporary user directory.

zshrc function

Suppress ZSH default message.

Internal 7 types, 51 functions and constants
Hooks class 92 members

tmux hooks data structure.

ControlMode class 9 members

Context manager that spawns a tmux control-mode client.

Skip default fields in dataclass object representation.

PKRequiredException exception 1 member
OpNotFound exception 1 member
QueryList class 7 members

Filter list of object/dictionaries. For small, local datasets.

SparseArray class 4 members

Support non-sequential indexes while maintaining list -like behavior.

__author__ constant
__docs__ constant
__email__ constant
__github__ constant
__license__ constant
__pypi__ constant
__title__ constant
__tracker__ constant
HookArray constant In libtmux._internal.constants
HookArray constant In libtmux._internal.sparse_array
logger constant In libtmux._internal.query_list
logger constant In libtmux.client
logger constant In libtmux.common
logger constant In libtmux.hooks
logger constant In libtmux.neo
logger constant In libtmux.options
logger constant In libtmux.pane
logger constant In libtmux.pytest_plugin
logger constant In libtmux.server
logger constant In libtmux.session
logger constant In libtmux.window
no_arg constant
StrPath constant
T constant In libtmux._internal.constants
T constant In libtmux._internal.query_list
T constant In libtmux._internal.sparse_array
TMUX constant

Environment variable tmux exports with socket_path,server_pid,session_id.

TMUX_PANE constant

Environment variable tmux exports with the pane's id, e.g. %3.

keygetter function

Fetch values in objects and keys, supported nested data.

lookup_exact function
lookup_iexact function
lookup_in function
lookup_iregex function
lookup_nin function
lookup_regex function

Return the pane id recorded in $TMUX_PANE.

parse_lookup function

Check if field lookup key, e.g. "my__path__contains" has comparator, return val.

resolve_env function

Return env, defaulting to the live process environment.

Return the tmux socket path recorded in $TMUX.

Internal — Options 5 types
ServerOptions class 23 members

Container for tmux server options.

SessionOptions class 55 members

Container for tmux session options.

WindowOptions class 48 members

Container for tmux window options.

PaneOptions class 19 members

Container for tmux pane options.

Options class 136 members

Container for all tmux options (server, session, window, and pane).

Other 2 types, 2 functions and constants
Obj class 180 members

Dataclass of generic tmux object.

__all__ constant

By module 73 modules

Esc

Type to search.

Reference preview Open reference