Categories
Linux

using sytem clipboard with tmux

If you are using tmux to handle your multiwindow console, you should be familiar with the copy text function (CTRL+A + [ then cursors and SPACE to select text then ENTER and insert with CTRL+Aa + ]) .

If you are also using the vim mode for navigating in copy mode you can set your Y key for yanking text into the system clipboard. So you can use ENTER for tmux internal copy and Y for copy to system clipboard.

First you should check that you have xclip installed, or you need to install it (here Ubuntu):

apt install xclip

Now you have to check your tmux version:

tmux -V

If you have tmux < 2.5, you have to add this to your tmux.conf (or enter it in live tmux session with CTRL+A + :)

bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'

If you have tmux >= 2.5, you have to add this to your tmux.conf:

bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

Of course this works by default only using a local tmux session.