Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-rs latest

Pane.hook

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

Source and package
Qualified name
libtmux::pane::Pane::hook
Module
pane
Declared in
Pane
Package
libtmux
Source
crates/libtmux/src/pane/settings.rs
pub async fn hook(&self, name: &str) -> Result< Option<IndexedHooks>, Error >

Description#

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.

Examples#

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("hooked").await?;
let window = session.active_window().await?.expect("a session has a window");
let pane = window.active_pane().await?.expect("a window has a pane");
assert!(pane.hook("pane-died").await?.is_none());
pane.set_hook("pane-died", "display-message rang").await?;
assert!(pane.hook("pane-died").await?.is_some());
guard.shutdown().await?;
Parameters

Guides#

Pages that discuss hook.

Esc

Type to search.

Reference previewOpen reference