Skip to content

Instantly share code, notes, and snippets.

@henrik
Created January 10, 2011 20:54
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save henrik/773446 to your computer and use it in GitHub Desktop.
Save henrik/773446 to your computer and use it in GitHub Desktop.
Search your own public Gists from the command line. Because the site only provides global search. There's not yet an API for private Gists.
require "open-uri"
require "rubygems"
require "json"
USERNAME = "henrik"
query = ARGV.first.downcase
gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{USERNAME}").read)['gists']
gists.each do |gist|
files = "(%s)" % gist['files'].join(', ')
description = gist['description']
unless description.to_s.downcase.include?(query) || files.downcase.include?(query)
next
end
puts description if description
puts files
puts "https://gist.github.com/gists/#{gist['repo']}"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment