With the introduction of https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard, it turns out tmux and pbcopy *can* play nicely. The Homebrew formula: require 'formula' class TmuxMacosxPasteboard < Formula head 'git://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git', :tag => "dadea0aa48259c704d0b412b9588de2f5623e323" homepage 'https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md'; def install system "make reattach-to-user-namespace" bin.install ["reattach-to-user-namespace"] end def caveats; <<-EOS.undent In your tmux config (typically ~/.tmux.conf): set-option -g default-command "reattach-to-user-namespace -l zsh" Kill your tmux server(s) or source your tmux config EOS end end This removes all the extra junk added; stakeout, a fake pboard that monitors ~/.current-output, etc. To copy from tmux within copy mode, just run: $> tmux_copy& This can be run inside tmux now, since pbcopy works. Whew.
NOTE: this assumes that the executables provided here are in ~/.dotfiles/bin - if not, tweak to your liking. So, there's the stakeout Ruby script that watches files and runs a command when they change. This watches ~/.current-output and pipes it to pbcopy so it's in the OS X clipboard. It cycles every half second. start_fake_pboard is a script that just kills any existing stakeout script and starts a new one. Now, this kinda hinders other usage of stakeout, but I'm not too worried at this point. tmux.conf gets a change where Ctrl+a Ctrl+c calls save-buffer to the ~/.current-output file, so whatever's the buffer will get written with that keypress. Finally, vim gets Ctrl+c, which writes what's visually selected to that same file. Finally, you'll have to run start_fake_pboard on your own. Since this is really only necessary on OS X, it makes sense to throw it in a plist file under ~/Library/LaunchAgents. Here's what mine looks like: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.joshuaclayton.fake_pboard</string> <key>ProgramArguments</key> <array> <string>/Users/joshuaclayton/.dotfiles/bin/start_fake_pboard</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>UserName</key> <string>joshuaclayton</string> <key>WorkingDirectory</key> <string>/Users/joshuaclayton/.dotfiles/bin</string> </dict> </plist> Obviously, you'll want to tweak to your liking (namely the path and the user you'll be running under. Again, it's a quick hack to get copy/paste working. I thought about digging into tmux's source and see how to get access to pboard, but this was a lot faster (albeit not ideal as a permenant fix).