Skip to content

Instantly share code, notes, and snippets.

@knksmith57
Created February 14, 2013 02:39
Show Gist options
  • Save knksmith57/4950199 to your computer and use it in GitHub Desktop.
Save knksmith57/4950199 to your computer and use it in GitHub Desktop.
domainr shell script
#!/usr/bin/env ruby
# encoding: utf-8
# From @jerodsanto
# http://blog.jerodsanto.net/2012/11/a-domainr-cli-in-less-than-15-lines-of-ruby/
%w(json open-uri).each { |lib| require lib }
abort "Usage: #{File.basename __FILE__} [query]" unless ARGV.first
response = open("http://domai.nr/api/json/search?q=#{ARGV.first}").read
JSON.parse(response)["results"].each do |domain|
symbol = if domain["availability"] == "available"
"\e[32m✓\e[0m" # 32 = green
else
"\e[31m✗\e[0m" # 31 = red
end
puts "#{symbol} #{domain['domain']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment