pbcopy / pbpaste in OS X

I came across a nifty utility in OS X that allows you to copy / paste data to/from the clipboard without having to select text and command+c/command+v

(michael)> echo foo | pbcopy

(michael)> pbpaste

Thats kind of neat.  What about connecting to a remote machine, executing some command, and then having that output in the clipboard of your local machine?

(michael)> ssh somehost.com uptime | pbcopy

(michael)> pbpaste
5:26pm  up 64 day(s),  8:30,  4 users,  load average: 0.04, 0.04, 0.04

5 thoughts on “pbcopy / pbpaste in OS X”

  1. I’d absolutely love it if there was some way of re-formatting a pbpaste result ( such as
    Macintosh HD:Users:esaruoho:folder actions:sceneorg_renoise:24017.html to (url/)24017.html :)
    and then copying it via pbcopy..

  2. esaruoho: this is unfinished — i did not bother writing the regex, but you can output pbpaste through a filter ; pbcopy it and then pbpaste the changed string:

    prompt$ pbpaste | sed -e “s/REGEX/URL$1/g” | pbcopy ; pbpaste

Leave a Reply

Your email address will not be published. Required fields are marked *