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.

Running tmux 1.4 installed from ports on snow-leopard I am unable to use the built in OSX pbcopy command.

Outside of tmux:

> echo "abc" | pbcopy
> echo $(pbpaste) # or using ^v
abc

But inside of tmux:

> echo "123" | pbcopy
> echo $(pbpaste)
abc

I've scoured the man page but can't find any options that might relate to this behaivor. I also can't understand why tmux would mess with shell redirection.

Anybody have any clues?

share|improve this question
1  
Note that this works using xclip on Linux. By the way, echo pbpaste should result in "pbpaste". –  Dennis Williamson Jan 10 '11 at 3:14

5 Answers 5

Using homebrew

brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste

or Macports

sudo port install tmux-pasteboard

Prepend the following to the top of ~/.tmux.conf

set-option -g default-command "reattach-to-user-namespace -l zsh"

Taken from => robots.thoughtbot.com

share|improve this answer
    
Works a charm. Thanks! –  Jonathan Aug 3 '12 at 11:32
4  
use bash if you're on bash instead of zsh –  three Oct 2 '12 at 6:48
    
my bash isn't initialized correctly (.bashrc, .bash_profile not sourced). How should this be done to do that? –  Brad Parks Mar 9 '13 at 11:44
1  
Must enable the option now brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste –  Ian Yang Aug 28 '13 at 14:14
3  
A more robust option for tmux.conf is set-option -g default-command "reattach-to-user-namespace -l $SHELL" –  khoomeister Apr 25 at 18:27

When tmux detaches from the console (in order to support attach/detach), it does so in a way that doesn't allow it to communicate with the GUI any more.

Apple's patches to GNU screen use a private system call to detach in a different way. There is a patch in the Macports bug tracker that makes pbcopy/pbpaste work again. I also submitted it to the Homebrew repo, where it was briefly accepted, then reverted.

This is because when this patch is applied, it causes tmux to crash when re-attaching to a session.

See the pull request on github for the Homebrew project for more info.

share|improve this answer

I found a github project that wraps tmux so that pbpaste and pbcopy work and doesn't have the issues described that caused Homebrew to remove the patch. It's pretty easy to install, just a small bit of compilation and one line in your .tmux.conf

Homebrew had a patch, but as others mentioned, it was backed out because it caused issues with reattaching.

There was an issue filed against tmux, but it was closed because the tmux author doesn't have a Mac to test on. The README on the github tmux-MacOSX-pasteboard project has great details on why patching tmux is difficult in this case, and a bunch of other info surrounding the situation. It works on OSX 10.6 for me and reading through the code looks like it will work for 10.5 as well.

share|improve this answer

There is an open ticket here: http://sourceforge.net/tracker/index.php?func=detail&aid=2960136&group_id=200378&atid=973265

Date: 2010-02-28 11:20:57 UTC Sender: nicm

There is no reason you can't just pipe tmux showb to it, of course.

Date: 2010-02-28 11:20:05 UTC Sender: nicm

Not unless someone sends me some code to do it or some hardware with OS X on it.

I tried piping showb to pbcopy and it didn't work.

~: echo "12345"
12345
[use copy-mode to copy "12345"]
~: tmux showb
12345
~: tmux showb | pbcopy
~: pbpaste

share|improve this answer

I use tmux-MacOSX-pasteboard on both Snow Leopard and Lion and it patches pbcopy/pbpaste functionality for you in tmux. Easy to install, too.

share|improve this answer
3  
tmux-MacOSX-pasteboard is now in macports as well with tmux-pasteboard name –  anddam Mar 31 '12 at 13:04

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.