Skip to content

Instantly share code, notes, and snippets.

@cmittendorf
Created July 11, 2013 20:32
Show Gist options
  • Save cmittendorf/5978982 to your computer and use it in GitHub Desktop.
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.
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