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

fetch_objs

Fetch a listing of raw data from a tmux command.

Source and package
Qualified name
libtmux.neo.fetch_objs
Module
libtmux.neo
Package
libtmux
Source
src/libtmux/neo.py
fetch_objs ( server: Server, list_cmd: ListCmd, list_extra_args: ListExtraArgs = None, filter: str | None = None, # noqa: A002, ) → OutputsRaw

Description#

Runs a tmux list command (e.g. list-sessions) with the format string from get_output_format and parses each line of output into a dict.

Examples#

>>> from libtmux.neo import fetch_objs
>>> objs = fetch_objs(server=server, list_cmd="list-sessions")
>>> isinstance(objs, list)
True
>>> isinstance(objs[0], dict)
True
>>> 'session_id' in objs[0]
True
Parameters
  • server (Server) # – The tmux server to query.

  • list_cmd (ListCmd) # – The tmux list command to run, e.g. "list-sessions", "list-windows", or "list-panes".

  • list_extra_args (ListExtraArgs) # – Extra arguments appended to the tmux command (e.g. ("-a",) for all windows/panes, or ["-t", session_id] to filter).

  • filter (str | None) # – Filter expression evaluated by tmux (-f flag). tmux omits rows whose expanded expression is false before libtmux parses the result. tmux silently expands a malformed filter (unclosed #{...}, unknown format token) to empty, which is treated as false — every row is suppressed and no stderr is emitted. A bad filter is indistinguishable from "filter matched nothing"; verify the expression against the FORMATS section of tmux(1). See native-filtering for the typed wrappers that share this caveat. Warning: added 0.57

  • # noqa: A002 #

Returns

OutputsRaw A list of dicts, each mapping tmux format field names to their non-empty string values.

Raises
Esc

Type to search.

Reference preview Open reference