Skip to content

Instantly share code, notes, and snippets.

@AndreasL
Created April 5, 2010 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AndreasL/356738 to your computer and use it in GitHub Desktop.
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.
#!/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