# LibTmux.Pane.wait_for_text/4

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/entities.ex#L781
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-pane-wait_for_text-4/

```
wait_for_text(connection, ref, text, options \\ [])
@spec wait_for_text(
        LibTmux.Action.connection(),
        LibTmux.Ref.t(),
        binary(),
        [text_wait_option()]
      ) ::
        {:ok, LibTmux.Action.result(binary())}
        | {:error,
           LibTmux.Error.t()
           | LibTmux.Action.CompletionError.t()}
```

Polls an exact pane through one-shot capture and returns the first matching screen.

The result has the same bounded bytes and capture evidence as `capture/3`.
`text` is 1..1048576 literal bytes. The default `match: :substring` searches
the captured bytes. `match: :line` requires one whole newline-delimited
line and rejects newlines in `text`. A match can be on the first screen.
To wait for an application receipt, choose text that typed input cannot
echo. The result observes the screen and carries no program exit status.

Range, byte and verification options follow `capture/3`. The default interval
is 100ms after a nonmatching capture. Identity checks, capture calls and intervals
share the original `timeout`, which defaults to 5000ms. Native retirement
can take its separate cleanup allowance. A Control connection returns
`unsupported_transport` before I/O.

An unmatched deadline returns `LibTmux.Error` with kind `:timeout` and phase
`:wait_for_text`. Its `details` include `expected`, `match`, `attempts`,
`elapsed_ms` and `last_screen`. The last screen is `nil` until a capture
completes. If a capture itself times out, its phase and transport evidence
remain in the error with the wait details under `details.text_wait`. Other
capture failures, including a missing pane, propagate with their evidence.

See the [worked receipt example](one-shot-actions.html).

## Parameters

- `connection` (`LibTmux.Action.connection()`)
- `ref` (`LibTmux.Ref.t()`)
- `text` (`binary()`)
- `options` (`[text_wait_option()]`)
  Default: `[]`.
