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.