public
Last active — forked from nicerobot/gist-backup.py

Clone or update all user's gists #backup #github #gists #management

  • Download Gist
gist-backup.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/env python
# Clone or update all a user's gists
# curl -ks https://gist.githubusercontent.com/fedir/5466075/raw/gist-backup.py | USER=fedir python
# USER=fedir 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?per_page=100')
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'])

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.