Skip to content

Instantly share code, notes, and snippets.

@pbt001
Forked from SpotlightKid/clone-gists.py
Created August 15, 2018 14:51
Show Gist options
  • Save pbt001/26f3b4eaf8dcc29d09524e20ce51a04e to your computer and use it in GitHub Desktop.
Save pbt001/26f3b4eaf8dcc29d09524e20ce51a04e to your computer and use it in GitHub Desktop.
Clone all gists of GitHub username given on the command line.
#!/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]
else:
print("Usage: clone-gists.py <GitHub username>")
sys.exit(1)
req = requests.get('https://api.github.com/users/%s/gists' % gh_user)
for gist in req.json():
ret = subprocess.call(['git', 'clone', gist['git_pull_url']])
if ret != 0:
print("***ERROR*** cloning gist %s. Please check output." % gist['id'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment