Skip to content

v0.50.0 - options and hook management

Choose a tag to compare

@tony tony released this 30 Nov 21:42
· 46 commits to master since this release

libtmux 0.50 brings a major enhancement to option and hook management with a unified, typed API for managing tmux options and hooks across all object types.

Highlights

  • Unified Options API: New show_option(), show_options(), set_option(), and unset_option() methods available on Server, Session, Window, and Pane
  • Hook Management: Full programmatic control over tmux hooks with support for indexed hook arrays and bulk operations
  • SparseArray: New internal data structure for handling tmux's sparse indexed arrays (e.g., command-alias[0], command-alias[99])
  • tmux 3.2+ baseline: Removed support for tmux versions below 3.2a, enabling cleaner code and full hook/option feature support

Unified Options API

All tmux objects now share a consistent options interface:

import libtmux

server = libtmux.Server()
session = server.sessions[0]
window = session.windows[0]

# Get all options as a structured dict
session.show_options()
# {'activity-action': 'other', 'base-index': 0, ...}

# Get a single option value
session.show_option('base-index')
# 0

# Set an option
window.set_option('automatic-rename', True)

# Unset an option (revert to default)
window.unset_option('automatic-rename')

Hook Management

Programmatic control over tmux hooks:

session = server.sessions[0]

# Set a hook
session.set_hook('session-renamed', 'display-message "Renamed!"')

# Get hook value (returns SparseArray for indexed hooks)
session.show_hook('session-renamed')
# {0: 'display-message "Renamed!"'}

# Get all hooks
session.show_hooks()

# Remove a hook
session.unset_hook('session-renamed')

# Bulk operations for indexed hooks
session.set_hooks('session-renamed', {
    0: 'display-message "Hook 0"',
    1: 'display-message "Hook 1"',
    5: 'run-shell "echo hook 5"',
})

Breaking Changes

Deprecated Window methods

The following methods are deprecated and will be removed in a future release:

Deprecated Replacement
Window.set_window_option() Window.set_option()
Window.show_window_option() Window.show_option()
Window.show_window_options() Window.show_options()

Deprecated g parameter

The g parameter for global options is deprecated in favor of global_:

# Before (deprecated)
session.show_option('status', g=True)

# After (0.50.0+)
session.show_option('status', global_=True)

New Constants

  • OptionScope enum: Server, Session, Window, Pane
  • OPTION_SCOPE_FLAG_MAP: Maps scope to tmux flags (-s, -w, -p)
  • HOOK_SCOPE_FLAG_MAP: Maps scope to hook flags

Documentation

  • New topic guide: Options and Hooks
  • New topic guides: Automation patterns, Workspace setup, Pane interaction, QueryList filtering
  • Refreshed README with hero section, quickstart, and more examples

tmux Version Compatibility

Feature Minimum tmux
All options/hooks features 3.2+
Window/Pane hook scopes (-w, -p) 3.2+
client-active, window-resized hooks 3.3+
pane-title-changed hook 3.5+

What's Changed

  • Improved option management, add hook management by @tony in #516
  • Refresh README by @tony in #609

Full Changelog: v0.49.0...v0.50.0