# io.github.libtmux.Pane.Pane.awaitText

- **Module:** io.github.libtmux.Pane.Pane
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-java/blob/842228310449e879ebcaa3f910597757c9dbffd6/libtmux/src/main/java/io/github/libtmux/Pane.java#L374
- **Page:** https://libtmux.org/en/java/latest/reference/io-github-libtmux-pane-pane-awaittext/

```
io.github.libtmux.Pane.Pane.awaitText(text: String, timeout: Duration) -> TextOutcome
```

Waits until this pane's text contains something, and says why the wait ended.

**Reach for this last.** It reads the screen on a timer, which is a heuristic
about a program's output rather than a fact about it, and the cheaper waits are exact:

  - If you wrote the command, append {@code ; tmux wait-for -S name} to it and block on
      {@link Server#channel}. tmux blocks server-side and returns on the signal itself, so
      nothing is inferred from the screen and one tmux process covers the whole wait. That is
      the only deterministic wait here, and it is the right one whenever the command is yours.
  - If you did not write the command — a daemon printing that it is ready, a build somebody
      else started — this is the case polling is for.

The timeout bounds the whole wait, reads included. Each read is given only what is left of
it, so a slow tmux cannot stretch a short wait out to the server's default deadline, and text
that first appears after the deadline is not reported. The first read alone is allowed at least
a quarter of a second, so a timeout shorter than one read can still answer
{@link TextOutcome#PRESENT_AT_ENTRY}.

Waiting longer is also less reliable, not more: tmux frees the oldest scrollback once
{@code history-limit} is reached, so a long wait on a productive pane can end up reading past
the lines it was watching for.

## Parameters

- `text` (String): the text to wait for, matched anywhere in a captured line
- `timeout` (Duration): how long to keep looking

## Returns

why the wait ended, which tells text that appeared from text that was already there

## Raises

- `LibTmuxException`: if a read fails while the server is still answering — most often because this pane was killed, which is not a timeout
- `InterruptedException`: if the waiting thread is interrupted, which is a cancellation rather than a timeout and so is not reported as one
