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.

Python API

method libtmux stable

Hooks.from_stdout

Parse raw tmux hook output into a Hooks instance.

Source and package
Qualified name
libtmux._internal.constants.Hooks.from_stdout
Module
libtmux._internal.constants
Declared in
Hooks
Package
libtmux
Source
src/libtmux/_internal/constants.py
from_stdout (cls, value: list[str]) → Hooks

Description#

The parsing pipeline:

  1. parse_options_to_dict() - Parse "key value" lines into dict
  2. explode_arrays(force_array=True) - Extract array indices into SparseArray
  3. explode_complex() - Handle complex option types
  4. Rename keys: session-renamed → session_renamed

Examples#

Basic parsing:

>>> from libtmux._internal.constants import Hooks
>>> raw = ["session-renamed[0] display-message 'renamed'"]
>>> hooks = Hooks.from_stdout(raw)
>>> hooks.session_renamed[0]
"display-message 'renamed'"

The pipeline preserves sparse indices:

>>> raw = [
... "after-select-window[0] refresh-client",
... "after-select-window[10] display-message 'selected'",
... ]
>>> hooks = Hooks.from_stdout(raw)
>>> sorted(hooks.after_select_window.keys())
[0, 10]

Empty input returns empty SparseArrays:

>>> hooks_empty = Hooks.from_stdout([])
>>> len(hooks_empty.session_renamed)
0
>>> hooks_empty.session_renamed.as_list()
[]
Parameters
Returns

Hooks Parsed hooks with SparseArray fields for each hook type.

tmux catalog Hooks

Esc

Type to search.

Reference preview Open reference