Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Clone all gist from specified account (requires Requests)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Clone all gists of GitHub username given on the command line."""
import subprocess
import sys
import requests
if len(sys.argv) > 1:
gh_user = sys.argv[1]
print("Usage: <GitHub username>")
i = 1
while True:
data = requests.get('{}/gists?page={}'.format(gh_user, i)).json()
# break if API returns no data
if not data:
for gist in data:
ret =['git', 'clone', gist['git_pull_url']])
if ret != 0:
print("ERROR cloning gist %s. Please check output." % gist['id'])
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment