Created
February 10, 2013 22:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> pbcopy "Test" | |
=> 4 | |
>> pbpaste | |
=> "Test" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment