# window.settings.Window.hook

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

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

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

There is deliberately no listing counterpart at this scope. tmux does
not enumerate hooks set on a window or a pane: `show-hooks` reports
nothing for them, and `show-options` omits them while still listing
ordinary options. A listing here could only ever answer empty, which
would read as "no hooks" rather than "tmux will not say". Reading one
by name works, so that is what is offered; [`crate::Server::hooks`] and
[`crate::Session::hooks`] list the scopes tmux does enumerate.

# 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?;
let window = session.new_window("w").await?;

assert!(window.hook("pane-died").await?.is_none());
window.set_hook("pane-died", "display-message rang").await?;
assert!(window.hook("pane-died").await?.is_some());

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