Pane.capture_lines
Capture with the per-line flags tmux records, marking shell prompts.
Source and package
- Qualified name
-
libtmux::pane:: Pane:: capture _lines - Module
- pane
- Declared in
Pane- Package
- libtmux
- Source
- crates/libtmux/src/pane/observe.rs
- pub async fn capture_lines( &self, options: Capture
Options ) -> Result<Vec<CapturedLine >, Error> -
Description#
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().has_behavior(&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?;- Parameters
tmux command#
The tmux commands behind capture_lines.
tmux C API#
The C declarations in tmux that implement these commands.