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

Session.set_hooks

Set multiple indexed hooks at once.

Source and package
Qualified name
libtmux.Session.set_hooks
Module
libtmux
Declared in
Session
Package
libtmux
Source
src/libtmux/hooks.py
Other languages
PowerShell Julia Ruby Lua TypeScript RustGo Java C# C++ Swift Kotlin Scala F#
set_hooks ( self, hook: str, values: HookValues, clear_existing: bool = False, global_: bool | None = None, scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE, ) → Self

Inherited from libtmux.hooks.HooksMixin

Examples#

Set hooks with explicit indices:

>>> session.set_hooks('session-renamed', {
... 0: 'display-message "hook 0"',
... 1: 'display-message "hook 1"',
... })
Session($...)
>>> hooks = session.show_hook('session-renamed')
>>> sorted(hooks.keys())
[0, 1]
>>> session.unset_hook('session-renamed')
Session($...)

Set hooks from a list (sequential indices):

>>> session.set_hooks('after-new-window', [
... 'select-pane -t 0',
... 'send-keys "clear" Enter',
... ])
Session($...)
>>> hooks = session.show_hook('after-new-window')
>>> sorted(hooks.keys())
[0, 1]

Replace all existing hooks with clear_existing=True:

>>> session.set_hooks(
... 'session-renamed',
... {0: 'display-message "new"'},
... clear_existing=True,
... )
Session($...)
>>> hooks = session.show_hook('session-renamed')
>>> sorted(hooks.keys())
[0]
>>> session.unset_hook('session-renamed')
Session($...)
>>> session.unset_hook('after-new-window')
Session($...)
Parameters
Returns

Self Returns self for method chaining.

tmux catalog Hooks

In other ports Write a session hook and its indexed commands at once
  • PowerShell
    No source-verified PowerShell equivalent is recorded for this operation.
  • Julia
    No source-verified Julia equivalent is recorded for this operation.
  • Ruby
    No source-verified Ruby equivalent is recorded for this operation.
  • Lua
    No source-verified Lua equivalent is recorded for this operation.
  • TypeScript
    no equivalent on Session
  • Rust
  • Go
  • Java
    no equivalent on Session
  • C#
    no equivalent on Session
  • C++
    no equivalent on Session
  • Swift
    no equivalent on Session
  • Kotlin
    No source-verified Kotlin equivalent is recorded for this operation.
  • Scala
    No source-verified Scala equivalent is recorded for this operation.
  • F#
    No source-verified F# equivalent is recorded for this operation.
Esc

Type to search.

Reference preview Open reference