qp2aha
Last Updated: February 25, 2016
·
6.572K
· weppos
99e0b39c091e10d9c7d4452a34ca52dc

Ruby pbcopy and pbpaste

pbcopy and pbcopy are two handy Mac OS X command line utilities to copy and paste content to the Clipboard.

The following Ruby methods provides access to the same utility using Ruby.

def pbcopy(input)
  str = input.to_s
  IO.popen('pbcopy', 'w') { |f| f << str }
  str
end

def pbpaste
  `pbpaste`
end

To make them available in IRB, add them to your ~/.irbrc file.

Say Thanks
Respond

1 Response
Add your response

14826
5230dda42237d8cff150ed51b01f43c6

This doesn't seem to work for me. Is there anything special you need to do for mavericks? Thanks!

over 1 year ago ·