New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to copy from tmux to the OS X clipboard #909

amelio-vazquez-reina opened this Issue May 4, 2017 · 8 comments


7 participants

amelio-vazquez-reina commented May 4, 2017

Original question here (SE.UX).

Hi This my be more a question of usage with a recent version than anything else, so apologies if this isn't the right forum! I used to be able to copy text from tmux to the OS X clipboard without problem, but not anymore. I have exhausted my options so am hoping to find a final answer here.

More specifically, the following code used to work in my .tmux.conf:

# Mac OS X:
bind-key -n -t emacs-copy M-w copy-pipe "reattach-to-user-namespace pbcopy"

# Move tmux copy buffer into x clipboard
unbind-key M-w
bind-key -n M-w run "tmux save-buffer - | xclip -i -selection clipboard" \; display-message 'Copying to clipboard'

It stopped working just recently, so I can't copy text anymore from tmux to elsewhere. I am guessing this is the result of upgrading tmux or reattach-to-user-namespace.

I now get the following error:

invalid or unknown command: bind-key -n -t emacs-copy M-w copy-pipe 
"reattach-to-user-namespace pbcopy"

Here are the versions I am using (from brew).



What may have changed, and how can I go about restoring my ability to copy from tmux to the system?

Installation notes:

# I am using the installation from brew
$ uname -sp && tmux -V && echo $TERM
Darwin i386
tmux 2.4

This comment has been minimized.

craigp commented May 4, 2017

@amelio-vazquez-reina I had the same issue, plus some other config errors - looking at the CHANGES file now I see some config options have changed. Pinning my version back to 2.3 got me working again until I have time to digest and apply the changes.


This comment has been minimized.

amelio-vazquez-reina commented May 4, 2017

Thans @craigp do you know (is it known) what the problem is? Is there a new way of getting this functionality back ? Or is it potentially a bug?


This comment has been minimized.

sunaku commented May 4, 2017

This is not a bug! 😱 Copy-mode shortcuts have undergone major incompatible changes. Try this instead:

bind-key -T copy-mode M-w send-keys -X copy-pipe 'reattach-to-user-namespace pbcopy'

This comment has been minimized.

amelio-vazquez-reina commented May 4, 2017

Thank you @sunaku That worked great. Good to know!


This comment has been minimized.

axelson commented May 9, 2017

Also if you want to display a tmux message at the same time you can add \: display-message "your message" to the end. Like so:

bind -T copy-mode M-w send -X copy-pipe "reattach-to-user-namespace pbcopy" \; display-message "copied to system clipboard"

Copied from: #599


This comment has been minimized.

stevenyap commented May 18, 2017

Adding to @sunaku's solution, I used copy-pip-and-cancel so that tmux will exit the copy mode.

bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"

nwbt added a commit to nwbt/sprout that referenced this issue Jul 6, 2017


This comment has been minimized.

unphased commented Sep 9, 2017

Does somebody know what M-y and M-w are? Aren't those just alt+y and alt+w. How do they relate to mouse mode...

Update: I found that it maybe should be this? MouseDragEnd1Pane. Yes! It works. Also helpfully fails silently on a Linux over ssh. 👍

Still confused why M-w is used in examples above. Actually I just successfully used it. you drag with mouse, hold it down... hit Alt+W. It does work. That UX is so unintuitive!!


This comment has been minimized.

krader1961 commented Sep 9, 2017

The M- prefix means apply the "meta" modifier to the next key. This is like "shift" or "ctrl" in that they all modify what the concurrent key press does. Back when things like the X11 windowing system was new this would only work with GUI apps, not those running inside a terminal. Then terminal emulators and applications like emacs realized it would be nice if the "meta" modifier key could be used with programs running inside a terminal. That lead to the convention that a terminal emulator would translate [meta-some_key] to send escape, \e, followed by whatever "some_key" would send. Fast forward to today where most keyboards have a key labeled "alt" that acts as the "meta" key. Also, most terminal emulators let you configure how the [meta] or [alt] keys behave. And the default behavior may not be to prefix the concurrent with an escape character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment