Copying and pasting with XWindow clipboard from `tmux`

Author:by Emre Şahin

tmux does not natively support XWindow’s clipboard. With two lines in .tmux.conf you can configure two keys to send and retrieve clipboard content.

Traditionally applications use PRIMARY selection which uses the mouse selection for copy and pastes with the third button. However this becomes less and less common, so I’ll configure the CLIPBOARD selection most newer browsers, applications and Emacs use.

Add following lines to .tmux.conf:

The first line sets C-b < in tmux to retrieve X clipboard contents and paste. The second line sets C-b > to send current tmux buffer to X clipboard for pasting to another application.

If you still like to use PRIMARY selection, you can drop b options from xsel, using xsel -o and xsel -i respectively.