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.

MoreLess about this notice

Configure and run hooks

Needs libtmux for PowerShell 0.x Install

Pass a server, session, window or pane to select a hook table, and choose a hook the scope supports.

  • Server hooks are global; tmux has no separate server table.
  • -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'

A TmuxHook has a base Name and Values, an ordered collection of TmuxHookEntry objects with Index and Command.

  • Get-TmuxHook accepts base names only; read Values for entries.
  • Without -Name, it lists the selected table.
  • A missing local hook produces 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. tmux normalizes it, and readback keeps that text so it can be passed back unchanged.
  • Without -PassThru, setting emits nothing.
  • An unindexed set replaces entries. -Append keeps them and lets tmux pick a free index, which can precede existing sparse indices. Use explicit indices when order matters.
  • Several changes are not an atomic replacement.

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

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

The call confirms tmux accepted it. A hook can start asynchronous work; to see it finish, signal from the hook and wait with Wait-TmuxChannel.

Remove one indexed entry, preserving its neighbours:

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

Use the base name to remove the whole local hook. Mutations support -WhatIf and -Confirm, and previews do no tmux I/O. Errors keep the native owner and core exception. -ErrorAction Continue lets later owners run, and Stop ends the pipeline. Cancellation cannot undo a command already sent.

Esc
Search in

Type to search.

Reference previewOpen reference