The basic way to copy text in tmux
Tmux uses its own clipboard system separate from your system clipboard, so copying text requires entering copy mode first. Press Ctrl+B followed by [ to enter copy mode — your cursor will change and you'll see a small indicator in the bottom right corner of the tmux window.
Once in copy mode, use arrow keys or Vi-style navigation (if your tmux is configured that way) to move your cursor to the start of the text you want to copy. Then hold Shift and press the arrow keys to select text, or use Space to start a selection and move to the end point, then press Enter to copy the selected text into tmux's buffer.
To paste what you've copied, press Ctrl+B followed by ]. The text will appear at your cursor position in the active tmux pane.
Key Takeaways
- Enter copy mode with Ctrl+B then [ to select and copy text within tmux.
- Use arrow keys or Vi keys to navigate, Shift+arrow to select, and Enter to confirm the copy.
- Paste copied text with Ctrl+B then ] into any tmux pane.
- Tmux's internal clipboard is separate from your system clipboard — you cannot directly paste system text into tmux without using the paste command.
- You can configure tmux to use Vi or Emacs key bindings, which changes how selection and navigation work in copy mode.
Using Vi keys for faster selection
If your tmux is set to use Vi key bindings (the default in most modern configurations), copy mode works differently than with Emacs keys. After pressing Ctrl+B then [, use h, j, k, and l to move left, down, up, and right instead of arrow keys.
Press v to start a visual selection, then continue moving with Vi keys until you've highlighted the text you want. Press y to copy (yank) the selection, and you'll automatically exit copy mode. This is faster than the arrow-key method because both navigation and selection use single keys.
If your tmux uses Emacs bindings instead, you'll use Ctrl+Space to start a selection and Ctrl+W to copy, but Vi bindings are more common in modern setups.
Copying text to your system clipboard
Tmux's internal buffer doesn't automatically sync with your system clipboard (the one you use with Ctrl+C and Ctrl+V in other programs). To copy tmux text directly to your system clipboard, you need to configure tmux to use a clipboard command.
On Linux with X11, add this line to your tmux configuration file (usually ~/.tmux.conf):
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
On macOS, use this instead:
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
After adding the line and reloading your tmux configuration (or restarting tmux), pressing y in copy mode will copy text to both tmux's buffer and your system clipboard at the same time.
Selecting entire lines or words quickly
Instead of manually selecting character by character, tmux copy mode offers shortcuts for larger selections. In Vi mode, press w to select the next word, b to select the previous word, or $ to select to the end of the line from your cursor position.
You can also select an entire line by pressing 0 to jump to the start of the line, then $ to select to the end. For selecting multiple lines, move to the first line you want, press v to start selection, then use j to move down and select additional lines.
These shortcuts save time when copying large blocks of text or specific sections of output, especially when you're working with long command results or log files.
Searching for text while copying
Tmux copy mode includes a search function so you can find specific text before selecting it. While in copy mode, press / to search forward or ? to search backward through the visible text. Type the text you're looking for and press Enter — tmux will jump to the first match.
Press n to jump to the next match or N to jump to the previous match. Once you've found the text you want, exit search mode by pressing Escape, then use your selection method (visual mode with v or word selection with w) to copy it.
This is especially useful when you're trying to copy a specific error message or value from a long terminal output without having to manually scroll and position your cursor.
Viewing and managing your copy buffer
Tmux stores multiple copies in a buffer list. To see everything you've copied recently, press Ctrl+B followed by # (or = on some systems). A menu will appear showing your last several copies, numbered from 0 (most recent) downward.
Use arrow keys to highlight the copy you want and press Enter to paste it. This is useful if you've copied multiple things and need to go back to an earlier copy without re-selecting it. You can also delete old copies from this menu by pressing d while a copy is highlighted.
By default, tmux keeps the last 50 copies in the buffer. You can change this limit by adding set -g buffer-limit 100 to your tmux configuration if you want to keep more history.
Troubleshooting common copy problems
If copy mode doesn't respond to your key presses, make sure you pressed Ctrl+B first — that's the tmux prefix key that tells tmux the next key is a command, not text for your shell. If Ctrl+B doesn't work, your tmux prefix might be configured differently; check your ~/.tmux.conf file for a line starting with set -g prefix.
If pasting doesn't work, you may have exited copy mode without confirming your selection. Go back into copy mode, select the text again, and press Enter (or y in Vi mode) to confirm. If text appears in the wrong place, make sure your cursor is in the correct pane before pasting — tmux pastes into whichever pane is currently active.
If you're trying to copy text that wraps across multiple lines, remember that tmux displays wrapped text as a single line internally. Select from the beginning of the text you want through to the end, and tmux will copy it correctly even if it appears to span multiple visual lines on your screen.
Frequently Asked Questions
Why can't I paste text from my terminal into tmux?
Tmux uses its own clipboard separate from your system clipboard. Text you copy in other programs won't automatically appear in tmux. You can configure tmux to sync with your system clipboard using xclip on Linux or pbcopy on macOS, as described in the system clipboard section above.
How do I copy text without using the mouse?
Enter copy mode with Ctrl+B then [, navigate with arrow keys or Vi keys (h, j, k, l), select with Shift+arrow or by pressing v, then press Enter or y to copy. This keyboard-only method works in any terminal and doesn't require mouse support.
Can I copy text from multiple tmux panes at once?
No, copy mode works on one pane at a time. You'll need to enter copy mode in each pane separately and copy the text you need from each one. If you need text from multiple panes, copy them one at a time and paste them into a file or editor.
What's the difference between pressing Enter and y to copy?
In Vi mode, pressing y copies the selection and exits copy mode automatically. Pressing Enter also copies but may keep you in copy mode depending on your configuration. Using y is generally faster because it does both actions at once.
How do I increase the number of lines tmux remembers for copying?
Add set -g history-limit 5000 to your ~/.tmux.conf file (adjust 5000 to however many lines you want). This controls how much scrollback tmux keeps, which determines how far back you can scroll and copy text from. The default is usually 2000 lines.