Created
February 14, 2013 02:39
-
-
Save knksmith57/4950199 to your computer and use it in GitHub Desktop.
domainr shell script
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/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