# session.Session.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#L353
- **Page:** https://libtmux.org/en/rs/latest/reference/session-session-hook/

```
session.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?;
```
