Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

Python API

method libtmux latest

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 hooks#

Events that run tmux commands, with the scope each hook belongs to and where tmux fires it.

Esc

Type to search.

Reference previewOpen reference