9

I'm converting a shell script which xclip and similar tools on Linux, to use pbpaste and pbcopy on Mac. The problem is the default pasteboard ('general' according to the man-page) for these tools is not the one being used by Stickies / Safari / TextMate / all the GUI apps.

I've tried all the pasteboard names mentioned in 'man pbpaste' but none contain the data I copy in any GUI app. If I load data into the 'general' pboard using 'pbcopy' I can extract it fine via 'pbpaste' - but it's separate from the GUI pasteboard.

Note I'm not running any unusual shell, Terminal or WindowServer settings, this is standard 10.7 Terminal and bash.

4
  • 1
    I can't replicate this issue. pbcopy and pbpaste work fine for me using the methods that you specified. Commented Jul 18, 2012 at 15:41
  • 1
    Just tested on a second machine, and indeed it works fine. So it's something specific to my config on that particular box. Unfortunately I have no idea what - there's nothing unusual in .profile, or .bashrc Commented Jul 18, 2012 at 16:36
  • Could you share a minimal script that exhibits the problem?
    – noffle
    Commented Jul 18, 2012 at 17:29
  • 2
    This sounds like classic symptoms of the pasteboard server having died (e.g., apple.stackexchange.com/q/31866/22570 and similar), which seems fairly common on Lion. If you restart, does it work?
    – Ken
    Commented Jul 18, 2012 at 18:30

4 Answers 4

4

As suggested in one of the comments, the issue was a confused pasteboard server - a restart of that made everything work as expected.

2
  • It probably has not been 24 hours yet, but be sure to accept your own answer when possible! Commented Jul 20, 2012 at 11:35
  • 5
    I have the same issue, how does one restart the pasteboard server?
    – grebneke
    Commented Feb 2, 2014 at 14:26
3

Check your bash aliases - is something aliasing pbcopy/pbpaste to use one of the other pasteboards?

The manpage for these commands mentions four possible pasteboards that they can use - general, ruler, find, and font. Try pbcopy -pboard general to force it to use the general pasteboard.

1
  • Already tried those options - the commands are using the general pasteboard, but my GUI apps are using some other pasteboard, it seems. Commented Jul 18, 2012 at 16:34
1

If you are using the command under tmux / screen, you need some settings. There're great post on this problem.

https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md

3
  • Answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone.
    – nohillside
    Commented Feb 18, 2014 at 14:48
  • "Answers on Ask Different need to be more than just a link." is the rule in this site? If so please give me the link referring to it as I'm pretty new here. I've posted this answer as it might be useful for who runs into the same problem that I had. And is already stand alone in another meaning as no other answer points it.
    – 9re
    Commented Feb 18, 2014 at 15:52
  • Let's call it a good practice. Links may break over time rendering your answer useless, it will frustrate any future user if he thinks he has found the answer but only gets a 404 error back. That's why we expect answer to stand on their own (and reference the source if applicable).
    – nohillside
    Commented Feb 18, 2014 at 19:39
0

It can happen that you get different clipboards,

  • one with the old apps started before the new clipboard is used,
  • and one with new apps which got started after the new clipboard was set.

So I guess the pasteboard used by the app will be set on startup of an app.


I currently have only Mail, Safari, TextEdit sharing a different clipboard, and all other apps sharing an older board. I believe I crashed/reset/recreated/duplicated the clipboard server by running the following command (ignoring man pboard(8) clearly stating Users should not run pboard manually.)

$ pboard

Sadly I couldn't yet figure out how to cleanly restart the server (except a reboot), but that is my best guess as to when/why the clipboard 'group' changed.

You must log in to answer this question.

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