Working with the Clipboard on Linux

Using the xclip utility,[10] you can integrate your buffers with the Linux system clipboard so you can more easily copy and paste between programs.

First, you have to install xclip. On Ubuntu, use this command:

 $ ​​sudo​​ ​​apt-get​​ ​​install​​ ​​xclip

Then add some new keybindings to use tmux’s save-buffer and set-buffer commands with xclip.

To copy the current buffer to the system clipboard, add this command to the .tmux.conf file:

 # Prefix Ctrl-C takes what's in the buffer and sends it to system clipboard
 # via xclip
 bind C-c run ​"tmux save-buffer - | xclip -sel clip -i"

This configures Prefix Ctrl-c so it pipes the current buffer to xclip.

So, you enter Copy ...

Get tmux 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.