On Thu, 25 Feb 2016 18:28:05 -0800, Sumonto Ghosh wrote:
> The buffer is copied to the remote OS X machine's clipboard instead
>
> bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
That is correct. tmux executes your copy-pipe command successfully,
but it does so on the *remote* machine that hosts your tmux session.
To understand why that setup is insufficient to affect your *client*
machine's clipboard, run "date | reattach-to-user-namespace pbcopy"
inside a brand new SSH session *without* attach tmux. Now, does
your client machine's clipboard contain the current date and time?
No? If you telephoned a friend who lives in a different city and
instructed them to cook dinner, would you expect the resulting meal
appear on your dinner table or theirs? Why, on *theirs*, of course!
The only way for the resulting meal to appear on *your* dinner table
is for it to be transported there. Thus, you need a way to somehow
transport your text selection from the remote machine to your client
machine *before* you attempt to copy it to your client's clipboard.
One unobtrusive way to do this is to use the OSC-52 escape sequence:
http://sunaku.github.io/tmux-yank-osc52.html
I don't know whether iTerm2 obeys the OSC-52 escape sequence; I've
only used it successfully under ChromeOS (hterm) and Linux (xterm).
Cheers.