Skip to content

Instantly share code, notes, and snippets.

@ashee
Created August 12, 2012 19:37
Show Gist options
  • Save ashee/3334028 to your computer and use it in GitHub Desktop.
Save ashee/3334028 to your computer and use it in GitHub Desktop.
Clone or refresh all my gists
#!/usr/bin/env ruby
# clone-mygists.rb : clones all mygists or refreshes them
require 'rubygems'
require 'json'
mygists = `curl -u ashee -qs https://api.github.com/users/ashee/gists`
gists = JSON.load(mygists)
gists.each do |g|
gid = g["id"].to_s
if !File.directory?(gid)
cmd = "git clone %s" % g["git_push_url"]
puts cmd
`#{cmd}`
puts
else
Dir.chdir(gid)
cmd = "git pull"
print "refreshing #{gid}..."
puts `#{cmd}`
Dir.chdir("../")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment