Skip to content

Instantly share code, notes, and snippets.

@olly
Created February 10, 2013 22:45
Show Gist options
  • Save olly/4751377 to your computer and use it in GitHub Desktop.
Save olly/4751377 to your computer and use it in GitHub Desktop.
A simple addition to access Mac OS X's pbcopy & pbpaste commands from IRB.
module Clipboard
def pbcopy(data)
IO.popen('pbcopy', 'w') {|io| io.write(data)}
end
def pbpaste
IO.popen('pbpaste', 'r').read
end
end
include Clipboard
>> pbcopy "Test"
=> 4
>> pbpaste
=> "Test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment