# libtmux:set-hook

- **Package:** libtmux
- **Language:** Common Lisp
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-lisp/blob/c2e5fc4ed3befda21f45dfa5d5868c38fd138311/src/configuration-operations.lisp#L201
- **Public owner:** libtmux
- **Page:** https://libtmux.org/en/lisp/latest/reference/libtmux-set-hook/

```
(set-hook client name command-source &key scope target (key nil key-p) append cancel-token timeout output-limit)
```

Install tmux COMMAND-SOURCE for one registered hook and return an outcome.
SCOPE/TARGET follow SET-OPTION. COMMAND-SOURCE is explicit tmux command
language, not Lisp code; this function neither reads nor executes it locally.
KEY selects one hook-array entry. APPEND applies to an unkeyed hook assignment;
tmux does not append command source within a keyed hook entry. The ordinary
install path never uses [set-hook](/en/tmux/latest/manual/set-hook/) -R, but tmux may still run a registered native
after-hook such as [`after-set-hook`](/en/tmux/latest/catalog/hooks/after-set-hook/) as a consequence of this [set-hook](/en/tmux/latest/manual/set-hook/) command.
Dynamic @ event sources require a live catalog that supports them. SET-OPTION
rejects registered hooks; use UNSET-HOOK to remove this state. Never retries.

See also: `libtmux:set-option`, `libtmux:unset-hook`.

## Parameters

- `client`
- `name`
- `command-source`
- `scope?`
- `target?`
- `key?`
- `append?`
- `cancel-token?`
- `timeout?`
- `output-limit?`

## tmux command

The tmux commands behind `set-hook`.

- [`set-hook`](/en/tmux/latest/manual/set-hook/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_set_hook_entry`](/en/tmux/latest/reference/c-variable-cmd_set_hook_entry/) (attribute)
- [`cmd_set_option_exec`](/en/tmux/latest/reference/c-function-cmd-set-option-c-cmd_set_option_exec/) (function)

## Guides

Pages that discuss `set-hook`.

- [Explicit operations](/en/lisp/latest/guides/operations/)
