libtmux Reference MCP Search
On this page

pane.observe.Pane.wait_for_text

View as Markdown

Module
pane.observe
Declared in
Pane
Package
libtmux
Source
crates/libtmux/src/pane/observe.rs
wait_for_text ( self , needle : impl AsRef<[u8]> , within : Duration ) Result<PaneWait, Error>
method [source]
method [source]
wait_for_text

Wait until this pane's output contains needle.

Polls rather than streams, so it needs no feature: a caller who dispatches a command needs to know when it finished, and Pane::send_keys without that is half an operation. A control-mode subscription would answer sooner and is not available in a default build.

Each look reads the scrollback rather than the visible screen, and joins lines tmux wrapped. Both matter for correctness rather than completeness: text that scrolled off before the look would otherwise be missed and reported as absent, and a line wider than the pane arrives split, so a needle spanning the wrap point would never match.

A pane whose process ends answers PaneWait::Dead rather than running to the deadline, because waiting longer cannot change it.

Errors

Returns an error when tmux cannot be reached or refuses a capture. Running out of time is PaneWait::TimedOut , not an error.

Examples

use libtmux::PaneWait;
use std::time::Duration;

pane.send_line("printf 'ready\\n'").await?;

let seen = pane.wait_for_text("ready", Duration::from_secs(10)).await?;
assert_eq!(seen, PaneWait::Arrived);

0 declared, 0 inherited

Esc

Type to search.