There are so many guides for copying to the clipboard from tmux to X11 and using the VI mode of tmux. I personally prefer to use the default mode with the default shortcuts. As such, I have looked and learned about using tmux list-keys which shows you existing short cuts to make my own to store in ~/.tmux.conf. To overwrite the default shortcuts:

set-option -s set-clipboard off
bind P paste-buffer
bind-key    -T copy-mode    C-w                  send-keys -X copy-pipe-and-cancel               wl-copy
bind-key    -T copy-mode    C-k                  send-keys -X copy-pipe-end-of-line-and-cancel   wl-copy

You can replace the wl-copy command with xsel or xclip if you want to use it with X11, you can even make a custom command to copy over ssh.

With this, you can ctl-b [ to enter copy mode, and use keyboard/mouse to move the cursor. Once the cursor is at the starting point, you can use ctl-space to start selection or ctl-k to copy to end of line. If you get a selection, use ctl-w to copy. The P bind is for pasting the buffer using ctl-b P.

I hope this helps someone.

Previous Post Next Post