On this page
libtmux.Pane.capture_pane
- Module
- libtmux
- Declared in
- Pane
- Package
- libtmux
- Source
- src/libtmux/pane.py
- Other languages
- TypeScriptRustGoJava.NETC++Swift
-
-
Capture text from pane.
$ 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.
In other languages Read a pane’s visible contents
- TypeScript
pane.Pane.capture - Rust
pane.observe.Pane.capture - Go
tmux.Pane.Capture - Java
io.github.libtmux.Pane.Pane.capture - .NET
LibTmux.Pane.CaptureAsync - C++
libtmux::Pane::capture - Swift
Server.capture(_:since:limit:)
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
$ const lines = await pane.capture();
lines.at(-1); 0 declared, 0 inherited