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.

function libtmux stable

get_output_format

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

Source and package
Qualified name
libtmux.neo.get_output_format
Module
libtmux.neo
Package
libtmux
Source
src/libtmux/neo.py
get_output_format ( list_cmd: str = "list-panes", tmux_version: str = "3.2a" ) → tuple[tuple[str, ...], str]

Description#

Only emits tokens whose scope is reachable from list_cmd (per SCOPES_BY_LIST_CMD ) and whose minimum tmux version (per FIELD_VERSION ) is at or below tmux_version. Runtime-only tokens (mouse_*, cursor_*, popups) are excluded from every list-* template — they only resolve in event-time format contexts.

Examples#

>>> from libtmux.neo import get_output_format
>>> fields, fmt = get_output_format("list-sessions", "3.6a")
>>> 'session_id' in fields
True
>>> 'pane_id' in fields # active pane for the listed session
True
>>> 'client_name' in fields # upward not allowed
False
>>> 'server' in fields
False

Pane scope picks up window and session tokens too:

>>> fields, _ = get_output_format("list-panes", "3.6a")
>>> all(t in fields for t in ('pane_id', 'window_id', 'session_id'))
True

list-clients adds fields for the attached client:

>>> fields, _ = get_output_format("list-clients", "3.6a")
>>> 'client_name' in fields
True
>>> 'pane_id' in fields
True
Parameters
  • list_cmd (str) # – The tmux list subcommand the format string is being built for. Determines which token scopes are reachable.

  • tmux_version (str) # – The live tmux version. Used to gate post-3.2a tokens. Defaults to "3.2a" (the project's minimum) for safe fallback when the caller can't yet detect the version.

Returns

tuple[tuple[str, ...], str] A tuple of (field_names, tmux_format_string) restricted to tokens the given list_cmd and tmux_version can resolve.

Esc

Type to search.

Reference preview Open reference