To copy text in tmux, you first need to enter copy mode.
- Press
Ctrl + bthen immediately press[→ This enters copy mode - Use arrow keys to navigate to the text you want to copy
- Press the spacebar to mark the starting point
- Use arrow keys to move to the endpoint
- Press
Enterto complete the copy operation - The copied text is now in the tmux internal buffer → Paste with
Ctrl + bthen]
By default, tmux doesn't integrate with the system clipboard, so tools like xclip, xsel, or pbcopy are needed.
- Install
xclip:sudo apt install xclip - Add the following to your
.tmux.conf:set-option -g set-clipboard on bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -in"
Add to your .tmux.conf:
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy"
- Press
Ctrl + b - Press
[to enter copy mode
- Navigate with arrow keys or mouse
- Press spacebar to set the starting point
- Move to the endpoint using arrow keys
- Press
yto copy (this will copy to the system clipboard viaxclipas configured)
Note: Previously you would press
Enter, but now you press theykey instead
- Press
Ctrl + Shift + Vto paste and verify - Alternatively, try pasting into a text editor or browser address bar
If your settings aren't working, reload your .tmux.conf with:
tmux source-file ~/.tmux.conf