Last active
August 29, 2015 14:04
-
-
Save phdelodder/97aed8a37e7191230cd6 to your computer and use it in GitHub Desktop.
Clone or update all a user's gists
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 python | |
# Source: http://stackoverflow.com/questions/6724490/pull-all-gists-from-github | |
# Clone or update all a user's gists | |
# curl -ks https://gist.githubusercontent.com/phdelodder/97aed8a37e7191230cd6/raw/f7843b9243f0b3d409cc25c2f11c9fdca39bb040/gist-backup.py | USER=phdelodder python | |
# USER=phdelodder python gist-backup.py | |
import json | |
import urllib | |
from subprocess import call | |
from urllib import urlopen | |
import os | |
USER = os.environ['USER'] | |
u = urlopen('https://api.github.com/users/' + USER + '/gists') | |
gists = json.load(u) | |
startd = os.getcwd() | |
for gist in gists: | |
gistd = gist['id'] | |
if os.path.isdir(gistd): | |
os.chdir(gistd) | |
call(['git', 'pull', 'git://gist.github.com/' + gistd + '.git']) | |
os.chdir(startd) | |
else: | |
call(['git', 'clone', 'git://gist.github.com/' + gistd + '.git']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment