tmux select then copy to clipboard

Using mouse to select text with tmux sometimes is inefficient. For my setup, I’ll have to press shift key during text selection and keyboard copy will convert empty line as spaces. The following 2 lines in the configuration file works with version 2.8 (latest at the time of writing).

As I am using Linux, the command line clipboard program is xclip. For mac users you need to use pbcopy.

Add those lines to your ~/.tmux.conf

bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -i -sel c"

Now when you are on the select mode (prefix+[), hit v or space to start selecting. After, press y to yank lines to clipboard. You can paste it anywhere else.

Join the conversation

1 Comment

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.