# pane.observe.Pane.capture_lines

- **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#L197
- **Page:** https://libtmux.org/reference/rs/pane-observe-pane-capture_lines/

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

Capture with the per-line flags tmux records, marking shell prompts.

tmux records where a prompt and its output begin from the OSC 133
sequences a shell emits, and keeps those marks as lines scroll into
history. That is what answers "show me the last command's output"
exactly, rather than by guessing at a prompt's shape.

Every [`CapturedLine::starts_prompt`] is `false` when the pane's shell
does not emit OSC 133, which is the common case: fish does, bash and
zsh do not without shell integration installed. An empty result is a
real answer about the shell, not a failure.

# Errors

Returns [`Error::UnsupportedCapability`] below tmux 3.7, which is where
`capture-pane -F` arrived, and an error when tmux refuses the capture.

## Example

```rust
use libtmux::CaptureOptions;

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
let session = server.new_session("prompts").await?;
let pane = session.panes().await?.remove(0);

if server.capabilities().await?.tmux_version().meets(&libtmux::since::CAPTURE_LINE_FLAGS) {
    let lines = pane.capture_lines(CaptureOptions::history()).await?;
    // Without shell integration nothing is marked, which is an answer.
    let prompts = lines.iter().filter(|line| line.starts_prompt).count();
    assert!(prompts <= lines.len());
}

guard.shutdown().await?;
```
