# Libtmux.Operations.set_hook

- **Module:** Libtmux
- **Package:** libtmux
- **Language:** OCaml
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ocaml/blob/205dfda49742592b479247049d186956e4a4cfe9/lib/libtmux.mli#L1202
- **Public owner:** Libtmux
- **Page:** https://libtmux.org/en/ocaml/latest/reference/libtmux-operations-set_hook/

```
val set_hook :
  ?index:int ->
  ?append:bool ->
  Options.scope -> name:string -> Hook.command list -> unit Command.t
```

Set a hook to a nonempty command list. Without an index, replace the whole hook array, or fill the lowest free index when appending. An explicit `@name` custom hook stores command text as a user option; it requires complete replacement and has no array indexes. `read_hook` returns its `Options.Text` value; bulk hook capture includes built-ins. Commands may cause arbitrary tmux effects when triggered. Hooks that print output are outside the supported control transport contract.

## Parameters

- `index?` (`int`)
- `append?` (`bool`)
- `arg1` (`Options.scope`)
- `name` (`string`)
- `arg2` (`Hook.command list`)
