I am running tmux inside gnome terminal and have been trying to use a binding to copy the contents of tmux's paste buffer to my Linux X clipboard. A lot of places on the internet recommend this:
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
This command works perfectly from the command line:
tmux save-buffer - | xclip -i -sel clipboard
If I bind the shell command to a key and use it from inside tmux (using bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
), it does copy the tmux save-buffer to my clipboard; once I have copied some text in tmux's "copy" mode, using this binding will load the text into my X clipboard, ready to be pasted into a browser or anywhere else.
However, it _also_ causes the prefix key to stop working for that terminal.
If I kill the terminal with tmux running inside it and open another terminal and re-attach to tmux, the prefix key will continue working in another terminal.
I also tried the following approach:
Set up an executable file: /usr/local/bin/tmux_to_clip
with the command in it
% cat /usr/local/bin/tmux_to_clip
#!/bin/bash
tmux save-buffer - | xclip -i -sel clipboard
and then call the command from inside tmux
:run tmux_to_clip
again, it successfully copies the command to the clipboard, but again it breaks the prefix key. How can I prevent this and get a keybinding for copying tmux save-buffer
to the X clipboard?
xclip
forks, although that is just a hunch for trying out as many combinations ofrun-shell
that I can (with pipes, without pipes, using other programs, etc). – magnus Feb 07 '17 at 01:27