I'm using a custom .tmux.conf file which looks like this:

unbind-key C-b
set -g prefix C-a
bind-key C-a send-prefix

set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

## CLIPBOARD selection integration
# Requires prefix key before the command key
# Copy tmux paste buffer to CLIPBOARD
bind C-y run "tmux show-buffer | xclip -i -selection clipboard"
# Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
bind C-p run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"

I'm using ctrl+a ctrl+y to copy from tmux copy buffer to clipboard. But every time I do this tmux freezes and does not accept any input. I tried to use ctrl+q but this doesn't help.

What can I do to prevent tmux from freezing, which shortcuts are interfering here? I also tried the shortcut ctrl+a ctrl+c, same problem here.

  • please consider adding that to your question so it looks nice. – Ashildr Oct 3 '13 at 13:29

If you type the xclip command on the command line you'll notice that it doesn't finish. This is because it continues to accept input until STDIN is done. Thus, STDOUT never gets closed. You can resolve this by redirecting the STDOUT of xclip to /dev/null. For example:

bind y run "tmux save-buffer - | xclip -selection clipboard &>/dev/null"

In this example I redirect STDERR as well just in case it matters.

| improve this answer | |
  • This is a very enlightening answer, but it does not solve the problem. For example, ps aux | grep xclip shows that the xclip process is still running, and continues to block the tmux terminal. Any suggestions for a command, like the one shown above, that also kills the xclip process? – modulitos Nov 18 '14 at 5:36

xclip is waiting for input, which blocks tmux from receiving input. The following example allows xclip to run in another shell without blocking your tmux session:

bind y run-shell -b "tmux save-buffer - | xclip -selection clipboard"

I would even add a message to help your workflow:

bind y run-shell -b "tmux save-buffer - | xclip -selection clipboard; tmux display-message \"Tmux buffer saved to clipboard\" "

I hope this helps!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.