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...
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 likebash --rcfile /dev/null
)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...?which
fail people with oddball cases andtype
never has failed me under bash. You're probably in the clear withwhich
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 ofpbcopy
command -v pbcopy
andtype pbcopy
both return/usr/bin/pbcopy
.