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
| Flag | Description |
|---|---|
| -p | Print to stdout instead of a buffer |
| -e | Include escape sequences for text and background attributes |
| -J | Join wrapped lines and preserve trailing spaces |
| -S start-line | Start line (use - for the start of history) |
| -E end-line | End line (use - for the end of visible content) |
| -b buffer-name | Name the destination buffer |
Examples
Print the visible pane to stdout
bash
tmux capture-pane -pPrint the entire scrollback history
bash
tmux capture-pane -pS -Save full scrollback to a file
bash
tmux capture-pane -pS - > pane.logDefault 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