# pane.observe.Pane.capture_with

- **Module:** pane.observe.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/pane/observe.rs#L121
- **Page:** https://libtmux.org/reference/rs/pane-observe-pane-capture_with/

```
pane.observe.Pane.capture_with(self, options: CaptureOptions) -> Result<Vec<TmuxText>, Error>
```

Read the pane's contents, choosing how much and in what form.

[`Pane::capture`] reads the visible screen. This reaches into
scrollback, which is where the output a caller is looking for has
usually gone by the time anyone asks.

# Errors

Returns an error when tmux refuses the capture, which includes a pane
that has been closed.

## Example

```rust
use libtmux::CaptureOptions;

let session = server.new_session("captured").await?;
let pane = session.panes().await?.remove(0);

let visible = pane.capture_with(CaptureOptions::visible()).await?;
let everything = pane.capture_with(CaptureOptions::history()).await?;
assert!(everything.len() >= visible.len());

let last_ten = pane.capture_with(CaptureOptions::visible().start(-10)).await?;
assert!(last_ten.len() >= visible.len());
```
