Created
July 11, 2013 20:32
-
-
Save cmittendorf/5978982 to your computer and use it in GitHub Desktop.
put this into your ~/.irbrc if you like do some text stuff in your ruby console which you want to paste somewhere else. Use "pbcopy a" to copy the contents of a to the pasteboard.
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
require 'tempfile' | |
def pbcopy(s) | |
tmp_file = Tempfile.new("pbcopy") | |
begin | |
tmp_file.write(s.to_s) | |
tmp_file.rewind | |
system "/bin/cat #{tmp_file.path} | /usr/bin/pbcopy" | |
ensure | |
tmp_file.close | |
tmp_file.unlink | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment