Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

MacVim's copy-paste stops working when I launch it from a tmux terminal (on zsh). If I exit tmux and then launch MacVim copy-past works. Any idea how to fix this?

share|improve this question
    
How are you copying? While I'm not familiar with your particular problem, in general, where one shortcut doesn't work another will. –  Yitzchak Feb 15 '11 at 3:12
    
command C/V. things work fine if i launch outside of tmux so it's definitely related to tmux –  Lisa Feb 15 '11 at 4:46

3 Answers 3

up vote 15 down vote accepted

You might try the patch mentioned in a related thread (“OSX 10.6.5 , Terminal.app, iTerm.app pbpaste, pbcopy do not work under tmux”) from the tmux-users mailing list (actually hosted at sf.net, but I abhor their archive interface).

Note: the patch was, at one time, applied to the MacPorts port, but it was later reverted when it was suspected to be causing other errors. However, those errors might have actually been caused by liking against the wrong version of libevent (and it seems that recent versions of tmux will work with either version of libevent).


Since helgeg brought it up, I’ll mention my notes on my attempt to use the above referenced patch.

Summary: I found the patch unreliable. It allowed pasteboard access, but it triggered many warning messages from my installation of libevent version 2 (maybe version 1 is less affected). It also prevents the tmux server from doing its normal fork(2) (via daemon(3)), which is a significant change to how the server process was designed to work.

I ended up publishing a program that works around the problem without patching tmux. People that have had problems using the pasteboard under tmux (and those for which the above patch does not work satisfactorily) might want to give my workaround a try.

share|improve this answer
    
that's a lot of links but great answer, thanks! –  Lisa Feb 15 '11 at 4:45
    
Thanks a lot for your investigation about this really annoying problem and brilliant solution, it works like a charm –  mko Sep 28 '12 at 2:19
    
Thanks a lot for this. I can copy text from iTerm and paste into mac vim started in tmux now. However, if I ^b + [ to start the browse mode, and use Space + Enter to select and copy text, I won't be able to paste it to mac vim. Please advice? –  Phuong Nguyen May 29 at 4:24
1  
@PhuongNguyen: exiting copy-mode like that just copies into a tmux buffer, not the Mac pasteboard. You could use a Vim command like :r!tmux save-buffer - to read the buffer. Or you could arrange to copy the data to the Mac pasteboard: tmux save-buffer - | reattach-to-user-namespace pbcopy (maybe as a tmux binding via run-shell) or (in tmux 1.8+) exit copy-mode with a binding like bind -t vi-copy y copy-pipe 'reattach-to-user-namespace pbcopy' (i.e. use this y instead of Enter once you have your selection). –  Chris Johnsen May 29 at 6:58
    
Thanks man. I'm using the binding to y now :D –  Phuong Nguyen May 29 at 7:14

Another hacky way to get around the issue that Chrish Johnsen described at length,

(long story short: Tmux loses access to the OS X paste buffer because of the way it launches itself)

is to always remember to open MacVim from the applications folder or a non tmux terminal session.

and use this

http://webexpose.org/2008/10/13/open-macvim-tabs-from-command-line

tutorial on always having files open in a new tab in the same MacVim window.

That MacVim window will already have access to the paste buffer and you won't have to go through the other hoops.

But you will have to remember to not launch MacVim with tmux on first load :(

share|improve this answer

Chris Johnsen has made a wrapper which solves the problem of using pbcopy and pbpase on OSX. https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard (the root cause of the MacVim problem above).

share|improve this answer
    
quick and easy ! great –  romeovs Nov 9 '11 at 19:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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