# pane.Pane.waitForText

- **Module:** pane
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/ad09eaef7ffff40f510989ee0695852c44a31576/packages/libtmux/src/pane.ts#L427
- **Page:** https://libtmux.org/en/ts/latest/reference/pane-pane-waitfortext/

```
waitForText(
  pattern: string | RegExp,
  options?: ProgramWaitOptions,
): Promise<string>
```

Resolve with the first line of this pane's screen that [`pattern`](/en/ts/latest/reference/selection-regexcriteriadata-pattern/) matches: a substring, or a regular expression tested against each line.

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`](/en/ts/latest/reference/errors-waittimeouterror/) and an abort throws [`TmuxTransportError`](/en/ts/latest/reference/errors-tmuxtransporterror/)
of kind `cancelled`. A pane whose program has exited without the text
rejects with [`LibTmuxError`](/en/ts/latest/reference/errors-libtmuxerror/).

Requires tmux 3.8 or newer.

## Examples

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

## Parameters

- `pattern` (`string | RegExp`)
- `options?` (`ProgramWaitOptions`)
