# LibTmux.Pane.capture/3

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

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

Captures bounded screen bytes through explicit one-shot execution.

Returns `{:ok, result}` with bytes as `value` after acknowledged completion
and native retirement. Failed commands return
`{:error, %LibTmux.Action.CompletionError{}}` with their original evidence.
Defaults: visible lines 0 through `:last`, no line joining, 65536 stdout
bytes, 65536 stderr bytes and 5000ms. `:last` is accepted only for `end_line`.
Negative line numbers include history;
tmux clamps the requested range to available lines. Output overflow is an
error, never a successful partial screen. This observes rendered screen
state, not the program's original output stream.

By default, `verify: :preflight` checks the incarnation before capture.
With `verify: :same_client`, a bounded passive probe reads the daemon PID
and start time. The capture client checks the pane ID, then reads the
daemon identity and screen on that same client. The identity must match
the probe, and the Linux incarnation must match the reference before and
after capture. Both reads share one deadline. The byte limit applies to
the screen. This mode requires native [`if-shell`](/en/tmux/latest/manual/if-shell/), [`list-commands`](/en/tmux/latest/manual/list-commands/) and
[`capture-pane`](/en/tmux/latest/manual/capture-pane/) semantics and hooks that preserve their output framing.

A Control argument returns `unsupported_transport`: arbitrary screen bytes
are not qualified for shared control framing. No fallback occurs.

    alias LibTmux.Pane

    Pane.capture(server, pane_ref, start_line: -100, max_bytes: 131_072)

## Parameters

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