# session.Session.set_hook

- **Module:** session.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/session/settings.rs#L205
- **Page:** https://libtmux.org/en/rs/latest/reference/session-session-set_hook/

```
session.Session.set_hook(self, name: &str, command: impl Into<OsString>) -> Result<(), Error>
```

Set one hook to a tmux command.

Hooks live in the same option tables, so a hook is an array option and
[`Self::typed_option`] reads it under an indexed name such as
`after-new-window[0]`.

# Errors

Returns an error when tmux rejects the hook name or command.

Returns [`crate::Error::OptionScopeMismatch`] when tmux keeps the
option in another of its tables.
