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.wait For Text - 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
WaitTimeoutErrorand an abort throwsTmuxTransportErrorof kindcancelled. A pane whose program has exited without the text rejects withLibTmuxError.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"