Core Library0.xGuides

Choose documentation 2

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.

Configure and run hooks

Use a native server, session, window or pane to select a hook table. Server hooks are global; tmux has no separate server hook table. Choose a hook supported in the selected scope. For reads and changes, -Scope overrides the scope and -Global requests global defaults; pane-local hooks stay local.

Inspect a configured hook on a previously selected $session:

Terminal window
$session | Get-TmuxHook -Name 'alert-bell'

Each native TmuxHook has a base Name and Values, an ordered collection of TmuxHookEntry objects with Index and Command. Get accepts base names only; inspect Values for individual entries. Omit -Name to list the selected table. Missing local hooks produce no objects.

Set one indexed command and inspect the complete grouped hook:

Terminal window
$command = 'display-message "build finished"'
$session | Set-TmuxHook -Name 'alert-bell[7]' -Command $command -PassThru

The command is tmux syntax, not PowerShell syntax. tmux normalizes it; readback preserves that normalized text so it can be passed back unchanged. Without -PassThru, setting emits no success output. An unindexed set replaces entries. -Append keeps them and lets tmux choose a free index, which may precede existing sparse indices. Use explicit indices when order matters. Multiple changes do not form an atomic replacement.

Run a previously configured base hook without waiting for its event. Invoke-TmuxHook uses tmux’s target-context lookup; -Scope and -Global do not force a particular table, and an indexed name does not select one entry:

Terminal window
$session | Invoke-TmuxHook -Name 'alert-bell'

The call confirms acceptance by tmux. A hook can start asynchronous work; use a producer signal and Wait-TmuxChannel to observe that work completing.

Remove one indexed entry, preserving its neighbours:

Terminal window
$session | Remove-TmuxHook -Name 'alert-bell[7]'

Use the base name to remove the local hook. Mutations support -WhatIf and -Confirm; previews perform no tmux I/O. Errors retain the native owner and core exception. -ErrorAction Continue permits later owners; Stop terminates the pipeline. Cancellation cannot undo a dispatched command.

Esc

Type to search.

Reference previewOpen reference