Core LibraryGuides

Choose documentation 2

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

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. -Scope overrides the scope and -Global selects its global table.

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 hook without waiting for its event:

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 preview Open reference