Created
April 5, 2010 19:18
-
-
Save AndreasL/356738 to your computer and use it in GitHub Desktop.
ruby shell script that takes a cl.ly URL as an argument and copies the actual file URL to the clipboard without HTML wrappers.
This file contains 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/ruby | |
require 'rubygems' | |
ARGV.each do |url| | |
cloud_url = "#{url}" | |
cloud_url = cloud_url+"/content" | |
args = cloud_url | |
@content = %x[curl #{args}] | |
regexp = Regexp.new(/http:\/\/(?:[^"\\]|\\.)*/) | |
matching = regexp.match(@content) | |
if matching | |
x = matching[0] | |
system("echo #{x} | pbcopy") | |
system("growlnotify -m \"Copied to Clipboard: #{x}\" -t \"Cloud.app\" -I \"/Applications/Cloud.app\"") | |
system("clear") | |
puts "Copied to Clipboard: #{x}" | |
else | |
system("clear") | |
puts "Cloud.app error" | |
end | |
end | |
# http://github.com/AndreasL | |
# recommended install: growlnotify (http://growl.info/documentation/growlnotify.php) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment