In this medium post from a while ago I talk about the flow
I use for copying and pasting for
tmux on macOS.
Now that I’m using a Linux desktop, time for an update! As a sidebar, I’m using Ubuntu, so this might not work on other distros.
The trick with copy/pasting is that you need way of communicating from Tmux to the X-window system, which manages your system clipboard on most Linux systems.
The solution to this is
You can install it on Debian-based systems with aptitude:
$ sudo apt-get install xclip
After that, simply add this to your
# For binding 'y' to copy and exiting selection mode bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i' # For binding 'Enter' to copy and not leave selection mode bind-key -T copy-mode-vi Enter send-keys -X copy-pipe 'xclip -sel clip -i' '\;' send -X clear-selection
Getting copy & paste from
vim to work on Linux is also a little tricky, and doesn’t work
out of the box. There are two main steps you need to take here:
clipboardsupport to vim.
You can check if your vim has clipboard support by typing the vim command:
If it says “1” (like mine does), it means you have it, otherwise you need to install a vim package that has it, like
In macOS, adding
clipboard=unnamedis enough to get copy/paste working. This command binds yanks in vim to the “*” register in vim, which in macOS corresponds to the system clipboard. In Linux, the “*” register is different– it typically corresponds to the “mouse selection”, which is different to the normal system keyboard. The normal system clipboard in Linux corresponds to the “+” register in vim. In order to get vim to bind yanks to this register, use the command:
For most setups, this should do the trick. If you are having trouble, the links below should be good starting points. Happy copypasta!
- (For older versions of tmux) http://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting-ubuntu/