e43eec99f94c00a6a9d2b30f9c449aff5ab0dfe5

Author
Matthew McCullough <matthewm@ambientideas.com>
Committer
Matthew McCullough <matthewm@ambientideas.com>
Date

Message

Added cloudapp from @holman of @GitHub fame

Diff

 1diff --git a/plugins/cloudapp/cloudapp.plugin.zsh b/plugins/cloudapp/cloudapp.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..99252f690b13c0d247024187858c759898d9474f
 4--- /dev/null
 5+++ b/plugins/cloudapp/cloudapp.plugin.zsh
 6@@ -0,0 +1,2 @@
 7+#!/bin/zsh
 8+alias cloudapp=$ZSH/plugins/cloudapp/cloudapp.rb
 9diff --git a/plugins/cloudapp/cloudapp.rb b/plugins/cloudapp/cloudapp.rb
10new file mode 100755
11index 0000000000000000000000000000000000000000..a11cfdb32be06a1fb1ea00933f306e2ff1e95715
12--- /dev/null
13+++ b/plugins/cloudapp/cloudapp.rb
14@@ -0,0 +1,60 @@
15+#!/usr/bin/env ruby
16+#
17+# cloudapp
18+# Zach Holman / @holman
19+#
20+# Uploads a file from the command line to CloudApp, drops it into your 
21+# clipboard (on a Mac, at least).
22+#
23+# Example:
24+#
25+#   cloudapp drunk-blake.png
26+#
27+# This requires Aaron Russell's cloudapp_api gem:
28+#
29+#   gem install cloudapp_api
30+#
31+# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of:
32+#
33+#   email
34+#   password
35+
36+require 'rubygems'
37+begin
38+  require 'cloudapp_api'
39+rescue LoadError
40+  puts "You need to install cloudapp_api: gem install cloudapp_api"
41+  exit!(1)
42+end
43+
44+config_file = "#{ENV['HOME']}/.cloudapp"
45+unless File.exist?(config_file)
46+  puts "You need to type your email and password (one per line) into "+
47+       "`~/.cloudapp`"
48+  exit!(1)
49+end
50+
51+email,password = File.read(config_file).split("\n")
52+
53+class HTTParty::Response
54+  # Apparently HTTPOK.ok? IS NOT OKAY WTFFFFFFFFFFUUUUUUUUUUUUUU
55+  # LETS MONKEY PATCH IT I FEEL OKAY ABOUT IT
56+  def ok? ; true end
57+end
58+
59+if ARGV[0].nil?
60+   puts "You need to specify a file to upload."
61+   exit!(1)
62+end
63+
64+CloudApp.authenticate(email,password)
65+url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
66+
67+# Say it for good measure.
68+puts "Uploaded to #{url}."
69+
70+# Get the embed link.
71+url = "#{url}/#{ARGV[0].split('/').last}"
72+
73+# Copy it to your (Mac's) clipboard.
74+`echo '#{url}' | tr -d "\n" | pbcopy`