Skip to content

Instantly share code, notes, and snippets.

@fmeyer
Created March 30, 2018 18:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmeyer/1c9289ca5e9dab0f105a4eaf6664638c to your computer and use it in GitHub Desktop.
Save fmeyer/1c9289ca5e9dab0f105a4eaf6664638c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# gist-backup
#
# Backs up all your public and private gists
# to the given directory.
#
# Example:
#
# gist-backup ~/gist-backups
#
# In addition to your own gists you can also backup your starred gists
# or (public) gists of a defined user by putting the gists url in an
# environment variable.
#
# Example:
#
# GIST_URL=https://api.github.com/gists/starred gist-backup ~/gist-backups/starred
# GIST_URL=https://api.github.com/users/aprescott/gists gist-backup ~/gist-backups/aprescott
#
token=$(git config --get github.gist.oauth.token)
url=${GIST_URL:-https://api.github.com/gists}
usage() {
cat <<END_USAGE
Usage:
gist-backup DIRECTORY
Example:
gist-backup ~/gist-backups
END_USAGE
if [ -z $token ]
then
cat <<END_USAGE_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment