Skip to content

Instantly share code, notes, and snippets.

@russ
Created August 31, 2010 22:07
Show Gist options
  • Save russ/559843 to your computer and use it in GitHub Desktop.
Save russ/559843 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rubygems"
require "uri"
require "open-uri"
require "net/http"
require "json"
host = "http://localhost:3000"
command = ARGV[0]
case command.downcase
when "search"
gems = JSON.parse(open("#{host}/color_schemes.json").read)
gems.each do |g|
if g["name"] =~ /#{ARGV[1]}/i
puts "#{g["name"]} (#{g["version"]})"
end
end
when "install"
g = JSON.parse(open("#{host}/color_schemes/#{ARGV[1]}.json").read)
url = "#{host}/files/color_schemes/#{g["file_name"]}"
puts "Downloading #{g["name"]} #{g["version"]} ..."
response = Net::HTTP.get_response(URI.parse(url))
File.open(File.join(ENV["HOME"], ".vim", "colors", url.split("/").last), "w") do |f|
f.write(response.body)
end
puts "#{g["name"]} #{g["version"]} Installed"
else
puts "Sorry, I don't know how to run \"#{command}\""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment