# libtmux.Server.set_hook

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/hooks.py#L118
- **Page:** https://libtmux.org/reference/py/libtmux-server-set_hook/

```
libtmux.Server.set_hook(self, hook: str, value: int | str, unset: bool | None = None, run: bool | None = None, append: bool | None = None, g: bool | None = None, global_: bool | None = None, scope: OptionScope | _DefaultOptionScope | None = DEFAULT_OPTION_SCOPE) -> Self
```

Set hook for tmux target.

Wraps ``$ tmux set-hook <hook> <value>``.

## Parameters

- `self`
- `hook` (str) — hook to set, e.g. 'aggressive-resize'
- `value` (int | str) — hook command.
- `unset` (bool | None)
- `run` (bool | None)
- `append` (bool | None)
- `g` (bool | None)
- `global_` (bool | None)
- `scope` (OptionScope | _DefaultOptionScope | None)

## Raises

- `exc.OptionError`
- `exc.UnknownOption`
- `exc.InvalidOption`
- `exc.AmbiguousOption`
