On this page
pane.observe.Pane.capture_lines
- Module
- pane.observe
- Declared in
- Pane
- Package
- libtmux
- Source
- crates/libtmux/src/pane/observe.rs
- 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_promptisfalsewhen 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::UnsupportedCapabilitybelow tmux 3.7, which is wherecapture-pane -Farrived, and an error when tmux refuses the capture.Examples
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?;
0 declared, 0 inherited