I want to use a clipboard manager in tmux. It is the CopyQ, but it does not matter, I guess. In ~/.tmux.conf I set following binding:

set-window-option -g mode-keys vi

bind C-y run 'out=`tmux save-buffer - ` && copyq add "$out"'

When I press this shortcut PREFIX, Ctrl-y the copying to CopyQ fails and the following message arises

'out=`tmux save-buffer - ` && copyq add "$out"' returned 127 

However, If I try to enter these commands manually then they works and text copyies from tmux buffer to copyq as required

$ out=`tmux save-buffer - `
$ copyq add "$out"

And I need to say that following command works fine and print a text from tmux buffer to screen:

bind C-w run 'out=`tmux save-buffer - ` && echo "$out"'

How I can make original binding work?


Value 127 is returned by your shell /bin/bash when any given command within your bash script or on bash command line is not found in any of the paths defined by PATH system environment variable.

So, tmux just have not CopyQ in its $PATH variable, when starts binding. If one add full path for CopyQ then it fix problem:

bind C-y run 'out=`tmux save-buffer - ` &&  /cygdrive/c/Program\ Files\ \(x86\)/CopyQ/copyq add "$out"'

Other approach is to add source ~/.bashrc to ~/bash_profile

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.