Hooks
tmux hooks data structure.
Source and package
- Qualified name
-
libtmux._internal .constants .Hooks - Module
- libtmux._internal.constants
- Package
- libtmux
- Source
- src/libtmux/_internal/constants.py
-
Description#
Parses tmux hook output into typed
SparseArrayfields, preserving array indices for hooks that can have multiple commands at different indices.Examples#
Parse raw tmux hook output:
>>> from libtmux._internal.constants import Hooks>>> raw = [... "session-renamed[0] set-option -g status-left-style bg=red",... "session-renamed[1] display-message 'session renamed'",... ]>>> hooks = Hooks.from_stdout(raw)Access individual hook commands by index:
>>> hooks.session_renamed[0]'set-option -g status-left-style bg=red'>>> hooks.session_renamed[1]"display-message 'session renamed'"Get all commands as a list (sorted by index):
>>> hooks.session_renamed.as_list()['set-option -g status-left-style bg=red', "display-message 'session renamed'"]Sparse indices are preserved (gaps in index numbers):
>>> raw_sparse = [... "pane-focus-in[0] refresh-client",... "pane-focus-in[5] display-message 'focus'",... ]>>> hooks_sparse = Hooks.from_stdout(raw_sparse)>>> 0 in hooks_sparse.pane_focus_inTrue>>> 5 in hooks_sparse.pane_focus_inTrue>>> 3 in hooks_sparse.pane_focus_inFalse>>> sorted(hooks_sparse.pane_focus_in.keys())[0, 5]Iterate over values in index order:
>>> for cmd in hooks_sparse.pane_focus_in.iter_values():... print(cmd)refresh-clientdisplay-message 'focus'Multiple hook types in one parse:
>>> raw_multi = [... "after-new-window[0] select-pane -t 0",... "after-new-window[1] send-keys 'clear' Enter",... "window-renamed[0] refresh-client -S",... ]>>> hooks_multi = Hooks.from_stdout(raw_multi)>>> len(hooks_multi.after_new_window)2>>> len(hooks_multi.window_renamed)1tmux catalog Hooks
Members91#
Common operations1#
- from_stdout method Parse raw tmux hook output into a Hooks instance.
Other members90#
- after_bind_key: Sparse
Array [str] attribute - after_capture_pane: Sparse
Array [str] attribute - after_copy_mode: Sparse
Array [str] attribute - after_display_message: Sparse
Array [str] attribute - after_display_panes: Sparse
Array [str] attribute - after_kill_pane: Sparse
Array [str] attribute - after_list_buffers: Sparse
Array [str] attribute - after_list_clients: Sparse
Array [str] attribute - after_list_keys: Sparse
Array [str] attribute - after_list_panes: Sparse
Array [str] attribute - after_list_sessions: Sparse
Array [str] attribute - after_list_windows: Sparse
Array [str] attribute - after_load_buffer: Sparse
Array [str] attribute - after_lock_server: Sparse
Array [str] attribute - after_new_session: Sparse
Array [str] attribute - after_new_window: Sparse
Array [str] attribute - after_paste_buffer: Sparse
Array [str] attribute - after_pipe_pane: Sparse
Array [str] attribute - after_queue: Sparse
Array [str] attribute - after_refresh_client: Sparse
Array [str] attribute - after_rename_session: Sparse
Array [str] attribute - after_rename_window: Sparse
Array [str] attribute - after_resize_pane: Sparse
Array [str] attribute - after_resize_window: Sparse
Array [str] attribute - after_save_buffer: Sparse
Array [str] attribute - after_select_layout: Sparse
Array [str] attribute - after_select_pane: Sparse
Array [str] attribute - after_select_window: Sparse
Array [str] attribute - after_send_keys: Sparse
Array [str] attribute - after_set_buffer: Sparse
Array [str] attribute - after_set_environment: Sparse
Array [str] attribute - after_set_hook: Sparse
Array [str] attribute - after_set_option: Sparse
Array [str] attribute - after_show_environment: Sparse
Array [str] attribute - after_show_messages: Sparse
Array [str] attribute - after_show_options: Sparse
Array [str] attribute - after_split_window: Sparse
Array [str] attribute - after_unbind_key: Sparse
Array [str] attribute - alert_activity: Sparse
Array [str] attribute - alert_bell: Sparse
Array [str] attribute - alert_silence: Sparse
Array [str] attribute - client_active: Sparse
Array [str] attribute - client_attached: Sparse
Array [str] attribute - client_dark_theme: Sparse
Array [str] attribute - client_detached: Sparse
Array [str] attribute - client_detached_control: Sparse
Array [str] attribute - client_focus_in: Sparse
Array [str] attribute - client_focus_out: Sparse
Array [str] attribute - client_light_theme: Sparse
Array [str] attribute - client_resized: Sparse
Array [str] attribute - client_session_changed: Sparse
Array [str] attribute - client_session_changed_control: Sparse
Array [str] attribute - command_error: Sparse
Array [str] attribute - config_error: Sparse
Array [str] attribute - continue_control: Sparse
Array [str] attribute - exit_control: Sparse
Array [str] attribute - extended_output: Sparse
Array [str] attribute - layout_change: Sparse
Array [str] attribute - message_control: Sparse
Array [str] attribute - output: Sparse
Array [str] attribute - pane_died: Sparse
Array [str] attribute - pane_exited: Sparse
Array [str] attribute - pane_focus_in: Sparse
Array [str] attribute - pane_focus_out: Sparse
Array [str] attribute - pane_mode_changed: Sparse
Array [str] attribute - pane_set_clipboard: Sparse
Array [str] attribute - pane_title_changed: Sparse
Array [str] attribute - paste_buffer_changed: Sparse
Array [str] attribute - paste_buffer_deleted: Sparse
Array [str] attribute - pause_control: Sparse
Array [str] attribute - session_changed_control: Sparse
Array [str] attribute - session_closed: Sparse
Array [str] attribute - session_created: Sparse
Array [str] attribute - session_renamed: Sparse
Array [str] attribute - session_renamed_control: Sparse
Array [str] attribute - session_window_changed: Sparse
Array [str] attribute - sessions_changed: Sparse
Array [str] attribute - subscription_changed: Sparse
Array [str] attribute - unlinked_window_add: Sparse
Array [str] attribute - unlinked_window_close: Sparse
Array [str] attribute - unlinked_window_renamed: Sparse
Array [str] attribute - window_add: Sparse
Array [str] attribute - window_close: Sparse
Array [str] attribute - window_layout_changed: Sparse
Array [str] attribute - window_linked: Sparse
Array [str] attribute - window_pane_changed: Sparse
Array [str] attribute - window_renamed: Sparse
Array [str] attribute - window_renamed_control: Sparse
Array [str] attribute - window_resized: Sparse
Array [str] attribute - window_unlinked: Sparse
Array [str] attribute
Inherited members1 member#
Reached through libtmux._internal.dataclasses.SkipDefaultFieldsReprMixin.