tmuxtmuxCLI Manual

Choose documentation 1

3.2a

tmux manual version

Latest (3.7c) 3.7c 3.2a
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

tmux capture-pane

Capture the contents of a pane.

Common uses

Run these commands inside tmux, in the pane you want to capture. TMUX_PANE identifies that pane.

Print the visible pane

tmux capture-pane -p -t "$TMUX_PANE"

Include up to 1,000 history lines and join wrapped lines

tmux capture-pane -p -J -S -1000 -t "$TMUX_PANE"

Syntax

tmux capture-pane [-aCeJNpPq] [-b buffer-name] [-E end-line] [-S start-line] [-t target-pane]

Alias: capturep.

Options

Output and line range

-p
Print to standard output. Without this flag, tmux saves the capture in a paste buffer.
-b name
Choose the paste buffer when -p is omitted. Without -b, tmux creates a new buffer.
-t pane
Choose the pane to capture. Inside tmux, "$TMUX_PANE" identifies the current pane.
-S start
First line to capture. Zero is the first visible line; negative numbers reach into history. Use - for the start of history.
-E end
Last line to capture. Use a line number, or - for the end of the visible pane. By default, capture only the visible pane.

Text formatting

-J
Join wrapped lines and preserve trailing spaces.
-e
Keep escape sequences for text attributes and colors.
-C
Escape non-printable characters as octal \xxx sequences.
-N
Preserve trailing spaces at the end of each line.

Screens and pending output

-a
Capture the alternate screen instead of the normal screen. History is unavailable. Fails if no alternate screen exists.
-q
With -a, suppress the error when no alternate screen exists.
-P
Capture a received but incomplete escape sequence, rather than the pane contents.
Original manual wording
Capture the contents of a pane. If -p is given, the output goes to stdout, otherwise to the buffer specified with -b or a new buffer if omitted. If -a is given, the alternate screen is used, and the history is not accessible. If no alternate screen exists, an error will be returned unless -q is given. If -e is given, the output includes escape sequences for text and background attributes. -C also escapes non-printable characters as octal \xxx. -N preserves trailing spaces at each line's end and -J preserves trailing spaces and joins any wrapped lines. -P captures only any output that the pane has received that is the beginning of an as-yet incomplete escape sequence.

-S and -E specify the starting and ending line numbers, zero is the first line of the visible pane and negative numbers are lines in the history. ‘-’ to -S is the start of the history and to -E the end of the visible pane. The default is to capture only the visible contents of the pane.

Guides

C implementation

Internal declarations in tmux 3.2a:

Use from a library

Each API describes its own defaults, errors and execution model.

tmux sources and license

Syntax comes from tmux 3.2a list-commands. See the global options for sockets and configuration, and command syntax and targets.

Behavior is taken from the tmux 3.2a manual.

Command declaration

Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Esc

Type to search.