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.

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 .

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"
Esc

Type to search.

Reference previewOpen reference