Pane.capture_pane
Capture text from pane.
Source and package
-
Description#
$ tmux capture-paneto pane.$ tmux capture-pane -S -10to pane.$ tmux capture-pane -E 3to pane.$ tmux capture-pane -S - -E -to pane.Examples#
>>> pane = window.split(shell='sh')>>> pane.capture_pane()['$']>>> pane.send_keys('echo "Hello world"', enter=True)>>> pane.capture_pane()['$ echo "Hello world"', 'Hello world', '$']>>> print(chr(10).join(pane.capture_pane()))$ echo "Hello world"Hello world$- Parameters
-
-
start(t.Literal ["-"] | int | None) # – Specify the starting line number. Zero is the first line of the visible pane. Positive numbers are lines in the visible pane. Negative numbers are lines in the history.-is the start of the history. Default: None -
end(t.Literal ["-"] | int | None) # – Specify the ending line number. Zero is the first line of the visible pane. Positive numbers are lines in the visible pane. Negative numbers are lines in the history.-is the end of the visible pane. Default: None -
escape_sequences(bool) # – Include ANSI escape sequences for text and background attributes (-eflag). Useful for capturing colored output. Default: False -
escape_non_printable(bool) # – Escape non-printable characters as octal\\xxxformat (-Cflag). Useful for binary-safe capture. Default: False -
join_wrapped(bool) # – Join wrapped lines and preserve trailing spaces (-Jflag). Lines that were wrapped by tmux will be joined back together. Default: False -
preserve_trailing(bool) # – Preserve trailing spaces at each line's end (-Nflag). Default: False -
trim_trailing(bool) # – Trim trailing positions with no characters (-Tflag). Only includes characters up to the last used cell. Requires tmux 3.4+. If used with tmux < 3.4, a warning is issued and the flag is ignored. Default: False -
alternate_screen(bool) # – Capture from the alternate screen (-aflag). Default: False added 0.56 -
quiet(bool) # – Suppress errors silently (-qflag). Default: False added 0.56 -
mode_screen(bool) # – Capture from the mode screen (e.g. copy mode) instead of the pane (-Mflag). Requires tmux 3.6+. Default: False added 0.56 -
pending(bool) # – Capture pending output — the bytes tmux has read from the pane but not yet committed to the terminal (-Pflag). These are bytes that begin an incomplete escape sequence and are still pending the parser's ground state (tmux'sinput_pending()/since_groundbuffer), distinct from the default capture (the pane's screen history). Useful for diagnosing programs whose output stalls mid-sequence. Default: False added 0.57 -
hyperlinks(bool) # – Capture only hyperlink targets in the selected lines (-Hflag). Requires tmux 3.7+. If used with tmux < 3.7, a warning is issued and the flag is ignored. Default: False -
line_numbers(bool) # – Prefix each captured line with its line number (-Lflag). Requires tmux 3.7+. If used with tmux < 3.7, a warning is issued and the flag is ignored. Default: False -
line_flags(bool) # – Prefix each captured line with its flags, e.g.Hfor a line with a hyperlink (-Fflag). Requires tmux 3.7+. If used with tmux < 3.7, a warning is issued and the flag is ignored. Default: False -
to_buffer(str | None) # – Write the capture into the named tmux buffer (-bflag) instead of returning it. When set,-pis omitted and the wrapper returnsNone. added 0.56
-
- Returns
-
list[str] or None Captured pane content, or
Nonewhen to_buffer is set.
tmux command#
The tmux commands behind capture_pane.
tmux C API#
The C declarations in tmux that implement these commands.
Guides#
Pages that discuss capture_pane.
In other ports#
Read a pane’s visible contents
| Language | Equivalent |
|---|---|
| Ruby | Lib |
| Lua | libtmux |
| Erlang | tmux |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | pane |
| Rust | pane |
| Go | tmux |
| Java | io |
| Clojure | libtmux |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib |
| C++ | libtmux:: |
| Swift | Server |
| OCaml | Libtmux |
| Perl | Lib Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes. |
No equivalent is recorded in PowerShell, Julia, Elixir or Common Lisp.