Skip to main content
Back to Commands
Copy ModeN/A (used in scripts)

capture-pane

Short form: capturep

Capture the contents of a pane into a paste buffer, or print them to stdout with -p. Useful for scripting, logging, or saving scrollback to a file.

Synopsis

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

Options

FlagDescription
-pPrint to stdout instead of a buffer
-eInclude escape sequences for text and background attributes
-JJoin wrapped lines and preserve trailing spaces
-S start-lineStart line (use - for the start of history)
-E end-lineEnd line (use - for the end of visible content)
-b buffer-nameName the destination buffer

Examples

Print the visible pane to stdout

bash
tmux capture-pane -p

Print the entire scrollback history

bash
tmux capture-pane -pS -

Save full scrollback to a file

bash
tmux capture-pane -pS - > pane.log

Default Keybinding

N/A (used in scripts)

Default prefix is Ctrl+b

Pro Tips

  • Use -S - to capture from the very start of history
  • Pair with shell redirection or save-buffer to write logs