libtmux Reference MCP Search
On this page

libtmux.neo.fetch_obj

View as Markdown

Module
libtmux.neo
Package
libtmux
Source
src/libtmux/neo.py
fetch_obj ( server : Server , obj_key : str , obj_id : str , list_cmd : ListCmd = "list-panes" , list_extra_args : ListExtraArgs = None ) OutputRaw
function [source]
function [source]
fetch_obj

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

A listing enumerates winlinks, so a window linked into one session at two indexes matches twice. _best_winlink then picks the row tmux itself would act on, rather than whichever sorted last.

Examples

>>> from libtmux.neo import fetch_obj
>>> fetch_obj(
...     server=pane.server,
...     obj_key="pane_id",
...     obj_id=pane.pane_id,
...     list_cmd="list-panes",
...     list_extra_args=("-t", pane.pane_id),
... )["pane_id"] == pane.pane_id
True

A pane that does not exist on a live server is a TmuxObjectDoesNotExist , not a bare tmux error:

>>> from libtmux import exc
>>> try:
...     fetch_obj(
...         server=pane.server,
...         obj_key="pane_id",
...         obj_id="%99999",
...         list_cmd="list-panes",
...         list_extra_args=("-t", "%99999"),
...     )
... except exc.TmuxObjectDoesNotExist as e:
...     print(e)
Could not find pane_id=%99999 for list-panes ('-t', '%99999')
Parameters
  • server ( Server ) – The tmux server to query.

  • obj_key ( str ) – Identity field to match, e.g. "pane_id".

  • obj_id ( str ) – Value the identity field must equal, e.g. "%3".

  • list_cmd ( ListCmd ) – tmux list subcommand to run.

  • list_extra_args ( ListExtraArgs ) – Extra arguments appended verbatim to the tmux command, e.g. ("-t", "%3") to scope the listing to one object's parent.

Returns

OutputRaw The matching row, as a dict of tmux format fields.

Raises
  • TmuxObjectDoesNotExistWhen the object does not exist -- whether tmux said so on stderr (can't find pane: %99, for a -t-scoped listing) or the object simply never appeared in the rows.

  • LibTmuxExceptionFor every other tmux failure, notably an unreachable server.

0 declared, 0 inherited

Esc

Type to search.