Wiki

Clone wiki

pb / Home

Why pb and not pbcopy/pbpaste?

For one thing, pb uses UTF-8 by default. (Someday, you'll be able to specify the default, but right now, it's hard-coded.) pbcopy/pbpaste use some 8-bit encoding, at least on my system. It's possible to convince them to use UTF-8, but that feature is undocumented, could go away, and causes problems if you do it incorrectly. (Specifically, don't set that key in environment.plist. Trust me.)

A more major feature is that pb supports any type of data—not just text. It uses Apple's Uniform Type Identifiers to name these types. For example, if you take a screenshot with the ctrl key down, it will go to the clipboard; if you then want it in a file, you can use pb to paste to one:

% pb paste public.png foo.png

That may save you a trip through Preview.

Also, pb lets you examine the clipboard. Try this with pbpaste:

% pb list
com.apple.pasteboard.clipboard
1 items

~#1: 2 flavors
        public.png (85528 bytes)
        com.apple.pict (308298 bytes)

You'll notice that it mentions a count of items. The Pasteboard Manager that Apple added in Mac OS X 10.3 supports multiple items on each pasteboard. pb supports this as well. (This is not terribly useful right now, as nothing else supports multiple items per pasteboard. To my knowledge, pb is the first program that does.)

One more: pb should support any named pasteboard on the system. pbcopy and pbpaste only handle four of the system-supplied pasteboards. (pb should be able to read the drag pasteboard, but this doesn't seem to work. I don't know why.)

Updated