Skip to content

Instantly share code, notes, and snippets.

@danopia
Created May 31, 2009 19:36
Show Gist options
  • Select an option

  • Save danopia/120998 to your computer and use it in GitHub Desktop.

Select an option

Save danopia/120998 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "open3"
# Puts "meep ity" on the clipboard:
# [danopia@danopia ~]$ clip meep ity
# Puts "meep ity\n" on the clipboard:
# [danopia@danopia ~]$ echo "meep ity"|clip
# Puts "meepity! lulz\n" on the clipboard: (use Ctrl-D)
# [danopia@danopia ~]$ clip
# meepity! lulz
# [danopia@danopia ~]$
# Puts "meepity! lulz" on the clipboard: (use Ctrl-D)
# [danopia@danopia ~]$ clip
# meepity! lulz[danopia@danopia ~]$
# Created by danopia becuase having to type "-selection clipboard" was
# driving me insane, plus I can also use ARGV :) Next up is reading
# files from ARGV.
Open3.popen3('xclip -selection clipboard') do |stdin, stdout, stderr|
if ARGV.size > 0
stdin.write ARGV.join(' ')
else
until $stdin.eof?
stdin.write $stdin.read(256)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment