MiscellaneousN/A (configuration command)
set-hook
Set (or unset) a hook that runs a tmux command automatically when an event occurs, such as a session being created or a window being linked. Flags mirror set-option.
Synopsis
bash
tmux set-hook [-agpRuw] [-t target-pane] hook-name [command]Options
| Flag | Description |
|---|---|
| -g | Set a global hook |
| -a | Append so the hook runs multiple commands |
| -u | Unset the hook |
| -R | Run the hook immediately |
| -t target-pane | Target pane/session for the hook |
Examples
Auto-apply the tiled layout to new windows
bash
tmux set-hook -g after-new-window 'select-layout tiled'Run a script whenever a session is created
bash
tmux set-hook -g session-created 'run-shell ~/on-session.sh'Default Keybinding
N/A (configuration command)
Default prefix is Ctrl+b
Pro Tips
- •List active hooks with show-hooks; many options also fire a *-changed hook
- •Use -a to attach several commands to one event