Skip to content

Instantly share code, notes, and snippets.

@mohnish
Created March 15, 2016 19:06
Show Gist options
  • Save mohnish/89cf5e7526725d2dacc9 to your computer and use it in GitHub Desktop.
Save mohnish/89cf5e7526725d2dacc9 to your computer and use it in GitHub Desktop.
clipboard interface for ruby
# (c) https://github.com/janlelis/clipboard/blob/master/lib/clipboard/mac.rb
require 'open3'
module Clipboard
extend self
def paste(_ = nil)
`pbpaste`
end
def copy(data)
Open3.popen3( 'pbcopy' ){ |input,_,_| input << data }
paste
end
def clear
copy ''
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment