Created
May 31, 2009 19:36
-
-
Save danopia/120998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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