xclip in a few lines of ruby

Update: I happened to check the source code of the ‘clipboard’ gem and it turns out that it depends on xclip. So the code below is just nonsense.

An xclip in a few lines of ruby

1
2
3
4
5
6
7
8
9
#!/usr/bin/env ruby
require 'clipboard'
if ARGV.empty?
Clipboard.copy ARGF.readlines.join("\n")
else
Clipboard.copy ARGV.join(' ')
end

###Use cases

1
2
3
4
5
#copy the html source of cosmicvent.com to clipboard
curl -s http://cosmicvent.com | xc
#copy date to clipboard
xc $(date)

I am currently working on Zammu which makes Automatic Deployment of static websites to Github Pages very easy. I would love to get your feedback on it, Use the invitation code KHAJA