Internal Constants - libtmux._internal.constants

Warning

Be careful with these! These constants are private, internal as they’re not covered by version policies. They can break or be removed between minor versions!

If you need a data structure here made public or stabilized please file an issue.

Internal constants.

class libtmux._internal.constants.ServerOptions[source]

Bases: SkipDefaultFieldsReprMixin

ServerOptions(**kwargs: ‘object’) -> ‘None’

backspace: str | None = None
buffer_limit: int | None = None
command_alias: SparseArray[str]
default_terminal: str | None = None
copy_command: str | None = None
escape_time: int | None = None
editor: str | None = None
exit_empty: Optional[Literal['on', 'off']] = None
exit_unattached: Optional[Literal['on', 'off']] = None
extended_keys: Optional[Literal['on', 'off', 'always']] = None
focus_events: Optional[Literal['on', 'off']] = None
history_file: str | None = None
message_limit: int | None = None
prompt_history_limit: int | None = None
set_clipboard: Optional[Literal['on', 'external', 'off']] = None
terminal_features: dict[str, list[str]]
terminal_overrides: SparseArray[str]
user_keys: SparseArray[str]
default_client_command: str | None = None
extended_keys_format: Optional[Literal['csi-u', 'xterm']] = None
__init__(**kwargs)[source]
Parameters:

kwargs (object)

Return type:

None

class libtmux._internal.constants.SessionOptions[source]

Bases: SkipDefaultFieldsReprMixin

SessionOptions(**kwargs: ‘object’) -> ‘None’

activity_action: Optional[Literal['any', 'none', 'current', 'other']] = None
assume_paste_time: int | None = None
base_index: int | None = None
bell_action: Optional[Literal['any', 'none', 'current', 'other']] = None
default_command: str | None = None
default_shell: str | None = None
default_size: str | None = None
destroy_unattached: Optional[Literal['on', 'off']] = None
detach_on_destroy: Optional[Literal['off', 'on', 'no-detached', 'previous', 'next']] = None
display_panes_active_colour: str | None = None
display_panes_colour: str | None = None
display_panes_time: int | None = None
display_time: int | None = None
history_limit: int | None = None
key_table: str | None = None
lock_after_time: int | None = None
lock_command: str | None = None
menu_style: str | None = None
menu_selected_style: str | None = None
menu_border_style: str | None = None
menu_border_lines: Optional[Literal['single', 'rounded', 'double', 'heavy', 'simple', 'padded', 'none']] = None
message_command_style: str | None = None
message_line: int | None = None
message_style: str | None = None
mouse: Optional[Literal['on', 'off']] = None
prefix: str | None = None
prefix2: str | None = None
renumber_windows: Optional[Literal['on', 'off']] = None
repeat_time: int | None = None
set_titles: Optional[Literal['on', 'off']] = None
set_titles_string: str | None = None
silence_action: Optional[Literal['any', 'none', 'current', 'other']] = None
status: Union[Literal['off', 'on'], int, None] = None
status_format: list[str] | None = None
status_interval: int | None = None
status_justify: Optional[Literal['left', 'centre', 'right', 'absolute-centre']] = None
status_keys: Optional[Literal['vi', 'emacs']] = None
status_left: str | None = None
status_left_length: int | None = None
status_left_style: str | None = None
status_position: Optional[Literal['top', 'bottom']] = None
status_right: str | None = None
status_right_length: int | None = None
status_right_style: str | None = None
status_style: str | None = None
update_environment: SparseArray[str]
visual_activity: Optional[Literal['on', 'off', 'both']] = None
visual_bell: Optional[Literal['on', 'off', 'both']] = None
visual_silence: Optional[Literal['on', 'off', 'both']] = None
word_separators: str | None = None
__init__(**kwargs)[source]
Parameters:

kwargs (object)

Return type:

None

class libtmux._internal.constants.WindowOptions[source]

Bases: SkipDefaultFieldsReprMixin

WindowOptions(**kwargs: ‘object’) -> ‘None’

aggressive_resize: Optional[Literal['on', 'off']] = None
automatic_rename: Optional[Literal['on', 'off']] = None
automatic_rename_format: str | None = None
clock_mode_colour: str | None = None
clock_mode_style: Optional[Literal['12', '24']] = None
fill_character: str | None = None
main_pane_height: int | str | None = None
main_pane_width: int | str | None = None
copy_mode_match_style: str | None = None
copy_mode_mark_style: str | None = None
copy_mode_current_match_style: str | None = None
mode_keys: Optional[Literal['vi', 'emacs']] = None
mode_style: str | None = None
monitor_activity: Optional[Literal['on', 'off']] = None
monitor_bell: Optional[Literal['on', 'off']] = None
monitor_silence: int | None = None
other_pane_height: int | str | None = None
other_pane_width: int | str | None = None
pane_active_border_style: str | None = None
pane_base_index: int | None = None
pane_border_format: str | None = None
pane_border_indicators: Optional[Literal['off', 'colour', 'arrows', 'both']] = None
pane_border_lines: Optional[Literal['single', 'double', 'heavy', 'simple', 'number']] = None
pane_border_status: Optional[Literal['off', 'top', 'bottom']] = None
pane_border_style: str | None = None
popup_style: str | None = None
popup_border_style: str | None = None
popup_border_lines: Optional[Literal['single', 'rounded', 'double', 'heavy', 'simple', 'padded', 'none']] = None
window_status_activity_style: str | None = None
window_status_bell_style: str | None = None
window_status_current_format: str | None = None
window_status_current_style: str | None = None
window_status_format: str | None = None
window_status_last_style: str | None = None
window_status_separator: str | None = None
window_status_style: str | None = None
window_size: Optional[Literal['largest', 'smallest', 'manual', 'latest']] = None
tiled_layout_max_columns: int | None = None
__init__(**kwargs)[source]
Parameters:

kwargs (object)

Return type:

None

class libtmux._internal.constants.PaneOptions[source]

Bases: SkipDefaultFieldsReprMixin

PaneOptions(**kwargs: ‘object’) -> ‘None’

allow_passthrough: Optional[Literal['on', 'off', 'all']] = None
allow_rename: Optional[Literal['on', 'off']] = None
alternate_screen: Optional[Literal['on', 'off']] = None
cursor_colour: str | None = None
pane_colours: list[str] | None = None
cursor_style: Optional[Literal['default', 'blinking-block', 'block', 'blinking-underline', 'underline', 'blinking-bar', 'bar']] = None
remain_on_exit: Optional[Literal['on', 'off', 'failed']] = None
remain_on_exit_format: str | None = None
scroll_on_clear: Optional[Literal['on', 'off']] = None
synchronize_panes: Optional[Literal['on', 'off']] = None
window_active_style: str | None = None
window_style: str | None = None
pane_scrollbars: Optional[Literal['off', 'modal', 'on']] = None
pane_scrollbars_style: str | None = None
__init__(**kwargs)[source]
Parameters:

kwargs (object)

Return type:

None

class libtmux._internal.constants.Options[source]

Bases: ServerOptions, SessionOptions, WindowOptions, PaneOptions, SkipDefaultFieldsReprMixin

Options(**kwargs: ‘object’) -> ‘None’

__init__(**kwargs)[source]
Parameters:

kwargs (object)

Return type:

None

activity_action: Optional[Literal['any', 'none', 'current', 'other']] = None
aggressive_resize: Optional[Literal['on', 'off']] = None
allow_passthrough: Optional[Literal['on', 'off', 'all']] = None
allow_rename: Optional[Literal['on', 'off']] = None
alternate_screen: Optional[Literal['on', 'off']] = None
assume_paste_time: int | None = None
automatic_rename: Optional[Literal['on', 'off']] = None
automatic_rename_format: str | None = None
backspace: str | None = None
base_index: int | None = None
bell_action: Optional[Literal['any', 'none', 'current', 'other']] = None
buffer_limit: int | None = None
clock_mode_colour: str | None = None
clock_mode_style: Optional[Literal['12', '24']] = None
copy_command: str | None = None
copy_mode_current_match_style: str | None = None
copy_mode_mark_style: str | None = None
copy_mode_match_style: str | None = None
cursor_colour: str | None = None
cursor_style: Optional[Literal['default', 'blinking-block', 'block', 'blinking-underline', 'underline', 'blinking-bar', 'bar']] = None
default_client_command: str | None = None
default_command: str | None = None
default_shell: str | None = None
default_size: str | None = None
default_terminal: str | None = None
destroy_unattached: Optional[Literal['on', 'off']] = None
detach_on_destroy: Optional[Literal['off', 'on', 'no-detached', 'previous', 'next']] = None
display_panes_active_colour: str | None = None
display_panes_colour: str | None = None
display_panes_time: int | None = None
display_time: int | None = None
editor: str | None = None
escape_time: int | None = None
exit_empty: Optional[Literal['on', 'off']] = None
exit_unattached: Optional[Literal['on', 'off']] = None
extended_keys: Optional[Literal['on', 'off', 'always']] = None
extended_keys_format: Optional[Literal['csi-u', 'xterm']] = None
fill_character: str | None = None
focus_events: Optional[Literal['on', 'off']] = None
history_file: str | None = None
history_limit: int | None = None
key_table: str | None = None
lock_after_time: int | None = None
lock_command: str | None = None
main_pane_height: int | str | None = None
main_pane_width: int | str | None = None
menu_border_lines: Optional[Literal['single', 'rounded', 'double', 'heavy', 'simple', 'padded', 'none']] = None
menu_border_style: str | None = None
menu_selected_style: str | None = None
menu_style: str | None = None
message_command_style: str | None = None
message_limit: int | None = None
message_line: int | None = None
message_style: str | None = None
mode_keys: Optional[Literal['vi', 'emacs']] = None
mode_style: str | None = None
monitor_activity: Optional[Literal['on', 'off']] = None
monitor_bell: Optional[Literal['on', 'off']] = None
monitor_silence: int | None = None
mouse: Optional[Literal['on', 'off']] = None
other_pane_height: int | str | None = None
other_pane_width: int | str | None = None
pane_active_border_style: str | None = None
pane_base_index: int | None = None
pane_border_format: str | None = None
pane_border_indicators: Optional[Literal['off', 'colour', 'arrows', 'both']] = None
pane_border_lines: Optional[Literal['single', 'double', 'heavy', 'simple', 'number']] = None
pane_border_status: Optional[Literal['off', 'top', 'bottom']] = None
pane_border_style: str | None = None
pane_colours: list[str] | None = None
pane_scrollbars: Optional[Literal['off', 'modal', 'on']] = None
pane_scrollbars_style: str | None = None
popup_border_lines: Optional[Literal['single', 'rounded', 'double', 'heavy', 'simple', 'padded', 'none']] = None
popup_border_style: str | None = None
popup_style: str | None = None
prefix: str | None = None
prefix2: str | None = None
prompt_history_limit: int | None = None
remain_on_exit: Optional[Literal['on', 'off', 'failed']] = None
remain_on_exit_format: str | None = None
renumber_windows: Optional[Literal['on', 'off']] = None
repeat_time: int | None = None
scroll_on_clear: Optional[Literal['on', 'off']] = None
set_clipboard: Optional[Literal['on', 'external', 'off']] = None
set_titles: Optional[Literal['on', 'off']] = None
set_titles_string: str | None = None
silence_action: Optional[Literal['any', 'none', 'current', 'other']] = None
status: Union[Literal['off', 'on'], int, None] = None
status_format: list[str] | None = None
status_interval: int | None = None
status_justify: Optional[Literal['left', 'centre', 'right', 'absolute-centre']] = None
status_keys: Optional[Literal['vi', 'emacs']] = None
status_left: str | None = None
status_left_length: int | None = None
status_left_style: str | None = None
status_position: Optional[Literal['top', 'bottom']] = None
status_right: str | None = None
status_right_length: int | None = None
status_right_style: str | None = None
status_style: str | None = None
synchronize_panes: Optional[Literal['on', 'off']] = None
tiled_layout_max_columns: int | None = None
visual_activity: Optional[Literal['on', 'off', 'both']] = None
visual_bell: Optional[Literal['on', 'off', 'both']] = None
visual_silence: Optional[Literal['on', 'off', 'both']] = None
window_active_style: str | None = None
window_size: Optional[Literal['largest', 'smallest', 'manual', 'latest']] = None
window_status_activity_style: str | None = None
window_status_bell_style: str | None = None
window_status_current_format: str | None = None
window_status_current_style: str | None = None
window_status_format: str | None = None
window_status_last_style: str | None = None
window_status_separator: str | None = None
window_status_style: str | None = None
window_style: str | None = None
word_separators: str | None = None
command_alias: SparseArray[str]
terminal_features: dict[str, list[str]]
terminal_overrides: SparseArray[str]
user_keys: SparseArray[str]
update_environment: SparseArray[str]
class libtmux._internal.constants.Hooks[source]

Bases: SkipDefaultFieldsReprMixin

tmux hooks data structure.

Parses tmux hook output into typed SparseArray fields, 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_in
True
>>> 5 in hooks_sparse.pane_focus_in
True
>>> 3 in hooks_sparse.pane_focus_in
False
>>> 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-client
display-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)
1
alert_activity: SparseArray[str]
alert_bell: SparseArray[str]
alert_silence: SparseArray[str]
client_active: SparseArray[str]
client_attached: SparseArray[str]
client_detached: SparseArray[str]
client_focus_in: SparseArray[str]
client_focus_out: SparseArray[str]
client_resized: SparseArray[str]
client_session_changed: SparseArray[str]
pane_died: SparseArray[str]
pane_exited: SparseArray[str]
pane_focus_in: SparseArray[str]
pane_focus_out: SparseArray[str]
pane_set_clipboard: SparseArray[str]
session_created: SparseArray[str]
session_closed: SparseArray[str]
session_renamed: SparseArray[str]
window_linked: SparseArray[str]
window_renamed: SparseArray[str]
window_resized: SparseArray[str]
window_unlinked: SparseArray[str]
pane_title_changed: SparseArray[str]
client_light_theme: SparseArray[str]
client_dark_theme: SparseArray[str]
client_detached_control: SparseArray[str]
client_session_changed_control: SparseArray[str]
config_error: SparseArray[str]
continue_control: SparseArray[str]
exit_control: SparseArray[str]
extended_output: SparseArray[str]
layout_change: SparseArray[str]
message_control: SparseArray[str]
output: SparseArray[str]
pane_mode_changed: SparseArray[str]
paste_buffer_changed: SparseArray[str]
paste_buffer_deleted: SparseArray[str]
pause_control: SparseArray[str]
session_changed_control: SparseArray[str]
session_renamed_control: SparseArray[str]
session_window_changed: SparseArray[str]
sessions_changed: SparseArray[str]
subscription_changed: SparseArray[str]
unlinked_window_add: SparseArray[str]
unlinked_window_close: SparseArray[str]
unlinked_window_renamed: SparseArray[str]
window_add: SparseArray[str]
window_close: SparseArray[str]
window_layout_changed: SparseArray[str]
window_pane_changed: SparseArray[str]
window_renamed_control: SparseArray[str]
after_bind_key: SparseArray[str]
after_capture_pane: SparseArray[str]
after_copy_mode: SparseArray[str]
after_display_message: SparseArray[str]
after_display_panes: SparseArray[str]
after_kill_pane: SparseArray[str]
after_list_buffers: SparseArray[str]
after_list_clients: SparseArray[str]
after_list_keys: SparseArray[str]
after_list_panes: SparseArray[str]
after_list_sessions: SparseArray[str]
after_list_windows: SparseArray[str]
after_load_buffer: SparseArray[str]
after_lock_server: SparseArray[str]
after_new_session: SparseArray[str]
after_new_window: SparseArray[str]
after_paste_buffer: SparseArray[str]
after_pipe_pane: SparseArray[str]
after_queue: SparseArray[str]
after_refresh_client: SparseArray[str]
after_rename_session: SparseArray[str]
after_rename_window: SparseArray[str]
after_resize_pane: SparseArray[str]
after_resize_window: SparseArray[str]
after_save_buffer: SparseArray[str]
after_select_layout: SparseArray[str]
after_select_pane: SparseArray[str]
after_select_window: SparseArray[str]
after_send_keys: SparseArray[str]
after_set_buffer: SparseArray[str]
after_set_environment: SparseArray[str]
after_set_hook: SparseArray[str]
after_set_option: SparseArray[str]
after_show_environment: SparseArray[str]
after_show_messages: SparseArray[str]
after_show_options: SparseArray[str]
after_split_window: SparseArray[str]
after_unbind_key: SparseArray[str]
command_error: SparseArray[str]
classmethod from_stdout(value)[source]

Parse raw tmux hook output into a Hooks instance.

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-renamedsession_renamed

Parameters:

value (list[str]) – Raw tmux output lines from show-hooks command.

Returns:

Parsed hooks with SparseArray fields for each hook type.

Return type:

Hooks

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()
[]
Return type:

Hooks

Parameters:

value (list[str])

__init__(alert_activity=<factory>, alert_bell=<factory>, alert_silence=<factory>, client_active=<factory>, client_attached=<factory>, client_detached=<factory>, client_focus_in=<factory>, client_focus_out=<factory>, client_resized=<factory>, client_session_changed=<factory>, pane_died=<factory>, pane_exited=<factory>, pane_focus_in=<factory>, pane_focus_out=<factory>, pane_set_clipboard=<factory>, session_created=<factory>, session_closed=<factory>, session_renamed=<factory>, window_linked=<factory>, window_renamed=<factory>, window_resized=<factory>, window_unlinked=<factory>, pane_title_changed=<factory>, client_light_theme=<factory>, client_dark_theme=<factory>, client_detached_control=<factory>, client_session_changed_control=<factory>, config_error=<factory>, continue_control=<factory>, exit_control=<factory>, extended_output=<factory>, layout_change=<factory>, message_control=<factory>, output=<factory>, pane_mode_changed=<factory>, paste_buffer_changed=<factory>, paste_buffer_deleted=<factory>, pause_control=<factory>, session_changed_control=<factory>, session_renamed_control=<factory>, session_window_changed=<factory>, sessions_changed=<factory>, subscription_changed=<factory>, unlinked_window_add=<factory>, unlinked_window_close=<factory>, unlinked_window_renamed=<factory>, window_add=<factory>, window_close=<factory>, window_layout_changed=<factory>, window_pane_changed=<factory>, window_renamed_control=<factory>, after_bind_key=<factory>, after_capture_pane=<factory>, after_copy_mode=<factory>, after_display_message=<factory>, after_display_panes=<factory>, after_kill_pane=<factory>, after_list_buffers=<factory>, after_list_clients=<factory>, after_list_keys=<factory>, after_list_panes=<factory>, after_list_sessions=<factory>, after_list_windows=<factory>, after_load_buffer=<factory>, after_lock_server=<factory>, after_new_session=<factory>, after_new_window=<factory>, after_paste_buffer=<factory>, after_pipe_pane=<factory>, after_queue=<factory>, after_refresh_client=<factory>, after_rename_session=<factory>, after_rename_window=<factory>, after_resize_pane=<factory>, after_resize_window=<factory>, after_save_buffer=<factory>, after_select_layout=<factory>, after_select_pane=<factory>, after_select_window=<factory>, after_send_keys=<factory>, after_set_buffer=<factory>, after_set_environment=<factory>, after_set_hook=<factory>, after_set_option=<factory>, after_show_environment=<factory>, after_show_messages=<factory>, after_show_options=<factory>, after_split_window=<factory>, after_unbind_key=<factory>, command_error=<factory>)[source]
Parameters:
Return type:

None