# session.settings.Session.hook

- **Module:** session.settings.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session/settings.rs#L293
- **Page:** https://libtmux.org/reference/rs/session-settings-session-hook/

```
session.settings.Session.hook(self, name: &str) -> Result<Option<IndexedHooks>, Error>
```

Read one hook's commands, or `None` when it holds nothing.

# Errors

Returns an error when tmux cannot be reached or refuses the listing.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("hooked").await?;

assert!(session.hook("alert-bell").await?.is_none());
session.set_hook("alert-bell", "display-message rang").await?;
assert!(session.hook("alert-bell").await?.is_some());

guard.shutdown().await?;
```
