Ubuntu Tmux – Tmux Xclip Copy No Longer Working

clipboardgnome-terminaltmuxUbuntuxclip

On mu Ubuntu 12.04 setups my tmux clipboard copy and paste commands are setup as follows:

set -g prefix M-a
unbind C-b
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

This worked great for the longest time up until a month or so ago, when I suspect some configuration change or package change was made that broke the above. In GNOME terminal, pasting still works fine with both prefix+ctrl-v and ctrl-shift-v.

However the xclip copy command no longer works no matter what I do, and I have tried removing the custom prefix binding above, using -select instead of -sel, not using clipboard etc. This is pretty much a show stopper for a GVim user like me, since I don't even have the GNOME terminal workaround of ctrl-shift-c with tmux taking over the shell. I go into copy mode, select text with space+movement, and when I execute prefix+ctrl-c absolutely nothing happens. Before this broke, tmux would display a confirmation message in the notification section at the bottom.

Does anybody have suggestions as far as how one might debug this? This is a pretty big productivity hit. I can probably use the temporary file workaround trick for now, but it'd be great to know just what happened to xclip.

Best Answer

The xsel utility is similar to xclip, but implemented a little differently. Normally I would expect them to behave in the same way, but they don't make exactly the same X library call, so it's possible that in some corner cases xsel will work but not xclip, or vice versa. Try:

bind C-c run "tmux save-buffer - | xsel -ib"
bind C-v run "tmux set-buffer \"$(xsel -ob)\"; tmux paste-buffer"
Related Question