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

But inside of tmux:

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

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

Anybody have any clues?

  • 1
    Note that this works using xclip on Linux. By the way, echo pbpaste should result in "pbpaste". Jan 10, 2011 at 3:14

6 Answers 6


Using homebrew

brew install reattach-to-user-namespace --with-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"

You might want to swap out the zsh for whichever shell you are using, for portability you should probably use $SHELL.

Taken from => robots.thoughtbot.com

  • 6
    use bash if you're on bash instead of zsh
    – three
    Oct 2, 2012 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, 2013 at 11:44
  • 1
    Must enable the option now brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste
    – Ian Yang
    Aug 28, 2013 at 14:14
  • 4
    A more robust option for tmux.conf is set-option -g default-command "reattach-to-user-namespace -l $SHELL"
    – Chris
    Apr 25, 2014 at 18:27
  • 5
    option --wrap-pbcopy-and-pbpaste was deprecated using --with-wrap-pbcopy-and-pbpaste instead!
    – TaeL
    Aug 6, 2016 at 9:57

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.

  • This would make sense... except that if I run, say, open . in a tmux session, it opens a Finder window just fine, so "doesn't allow it to communicate with the GUI any more" doesn't seem quite accurate?
    – jamesdlin
    Jun 29, 2018 at 0:57

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.


This issue is solved with the latest release ( 2.6 ) changelog https://raw.githubusercontent.com/tmux/tmux/2.6/CHANGES .


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"
[use copy-mode to copy "12345"]
~: tmux showb
~: tmux showb | pbcopy
~: pbpaste


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.

  • 3
    tmux-MacOSX-pasteboard is now in macports as well with tmux-pasteboard name
    – anddam
    Mar 31, 2012 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .