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-ts latest

Pane.waitForText

Resolve with the first line of this pane's screen that pattern matches: a substring, or a regular expression tested against each line. A line the pane's width wrapped is one line here, matched and returned whole, so the result can be wider than the pane.

Source and package
Qualified name
Pane.waitForText
Module
pane
Declared in
Pane
Package
libtmux
Source
packages/libtmux/src/pane.ts

Description#

The screen is read at once, then again each time tmux reports that the pane printed, at most every 50 ms, and once a second besides. Use it to wait for a prompt, or for a full-screen program's first screen before typing into it. Giving up leaves the pane as it was: a timeout throws WaitTimeoutError and an abort throws TmuxTransportError of kind cancelled. A pane whose program has exited without the text rejects with LibTmuxError, and a pane that is gone, or goes during the wait, with ObjectNotFoundError.

Requires tmux 3.8 or newer.

Examples#

await using top = await server.spawn(["sh", "-c", "echo ready; exec cat"]);
await top.pane.waitForText("ready", { timeoutMs: 10_000 }); // "ready"

tmux command#

The tmux commands behind waitForText.

tmux C API#

The C declarations in tmux that implement these commands.

Esc

Type to search.

Reference previewOpen reference