5

I'm trying to use pbcopy and pbpaste to copy and paste to the clipboard from a shell. I read the man page to learn the syntax for these programs. However, no matter how I try to invoke pbcopy or pbpaste, they refuse to work, exiting code 1 with no error message. Command-C and Command-V work as normal.

[jay-mba-osx ~]% echo foo | pbcopy                                                                                                                                          
[jay-mba-osx ~]% echo $?                                                                                                                                                    
1
[jay-mba-osx ~]% pbcopy < foo.txt                                                                                                                                        
[jay-mba-osx ~]% echo $?                                                                                                                                                    
1
[jay-mba-osx ~]% echo foo | pbcopy -pboard general                                                                                                                          
[jay-mba-osx ~]% echo $?                                                                                                                                                    
1
[jay-mba-osx ~]% pbcopy --help                                               
[jay-mba-osx ~]% echo $?
1
[jay-mba-osx ~]% which pbcopy                                                                                                                                               
/usr/bin/pbcopy
[jay-mba-osx ~]% pbpaste                                                                                                                                                    
[jay-mba-osx ~]% echo $?                                                                                                                                                    
1

Any ideas why this is happening? It persists across reboots.

EDIT: OS X 10.9 Mavericks. Here is the result of uname -a:

Darwin jay-mba-osx.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

EDIT2: I have isolated this to occur only in tmux sessions. I didn't even think about that at first... now to figure out the actual problem...

  • 2
    Does type pbcopy also show it being in /usr/bin and is there any chance you have several OS installed / available or some off $PATH variable? Can we also presume you're in bash or have reproduced this with a stock shell (or something like bash --rcfile /dev/null) – bmike Jan 1 '14 at 17:33
  • Yes, pbcopy is /usr/bin/pbcopy. This was noted in my original question. ;) Yes, I have Windows and Debian Linux installed on this machine, but I don't see how that would have any effect...? – jayhendren Jan 1 '14 at 17:37
  • I've seen which fail people with oddball cases and type never has failed me under bash. You're probably in the clear with which but I wanted to rule some oddball edge case of a function or improperly hashed command out. I should have been more specific - older versions of OS X or darwin was all I was wondering in case you ran an incorrect version of pbcopy – bmike Jan 1 '14 at 17:39
  • I see what you're getting at. :) command -v pbcopy and type pbcopy both return /usr/bin/pbcopy. – jayhendren Jan 1 '14 at 17:40
  • Oh, no, OSX 10.9 (Mavericks). Sorry. I'll add that to my question. – jayhendren Jan 1 '14 at 17:41
4

It is a problem with tmux detaching itself from the GUI namespace.

Fixed with: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard

You must log in to answer this question.

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