Copy-Paste Workflow
Tmux uses its own paste buffer system, separate from your terminal's clipboard. Understanding this workflow saves time and prevents frustration.
Learning Focus
Learn the three types of copy paths: tmux buffer, terminal native selection (Shift+drag), and system clipboard integration.
Three Ways to Copy in Tmux
| Method | How | Paste with |
|---|---|---|
| Tmux buffer (copy mode) | Ctrl+b [ → select → y | Ctrl+b ] |
| Terminal native | Hold Shift + click/drag | Mouse middle-click or terminal paste |
| System clipboard | Copy mode → pipe to xclip/pbcopy | OS paste (Ctrl+V or middle-click) |
Method 1: Tmux Buffer (Standard)
1. Ctrl+b [ → Enter copy mode
2. Navigate to text → use vim keys: h j k l / g G
3. v → start selection (vi mode)
4. Move to end → extend selection
5. y → copy to tmux buffer, exit mode
6. Ctrl+b ] → paste from buffer
Method 2: Terminal Native Selection
Hold Shift while using your mouse to select text. This bypasses tmux and uses your terminal emulator's native copy/paste:
- Copy:
Shift+clickand drag, thenCtrl+Shift+C(or terminal-specific) - Paste:
Ctrl+Shift+Vor middle-click
note
This works even when tmux mouse mode is ON, because Shift bypasses tmux mouse capture.
Method 3: System Clipboard Integration
Add to ~/.tmux.conf:
~/.tmux.conf
# Linux with xclip
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel clipboard"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -sel clipboard"
# macOS
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
Now y in copy mode sends to the system clipboard directly.
Multiple Buffers
Tmux keeps a history of copied buffers:
# List all buffers
tmux list-buffers
# Paste specific buffer (interactive list)
Ctrl+b =
# Paste buffer by index
tmux paste-buffer -b 0
# Show content of most recent buffer
tmux show-buffer
# Save buffer to a file
tmux save-buffer -b 0 ~/clipboard.txt
# Load file to buffer
tmux load-buffer ~/clipboard.txt
# Delete a buffer
tmux delete-buffer -b 0
Copying Multi-Line Content
Rectangle selection is useful for columns:
~/.tmux.conf
# Toggle rectangle selection with r
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
Use:
- Enter copy mode:
Ctrl+b [ - Position cursor at top-left of target area
- Press
rto enable rectangle selection - Move to bottom-right
- Press
yto copy
Practical Copy Workflow for Logs
Scenario: copy an error message from a log tail
1. In a pane showing: tail -f /var/log/app.log
2. Press Ctrl+b [ → freeze view, enter copy mode
3. Press G → jump to latest output
4. Navigate to error line
5. Press v → start selection
6. Press $ → line end (or extend with j for multiple lines)
7. Press y → copy
8. Press Ctrl+b ] → paste wherever you need it
Common Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Pasting overwrites instead of inserting | Pasted text replaces content in editor | Position cursor correctly before pasting |
| Tmux buffer vs system clipboard confusion | Wrong content pasted | Know which buffer you are using |
| Copy mode freezes the pane | "Nothing is updating" | You are in copy mode — press q to exit |