Created
March 30, 2018 18:57
-
-
Save fmeyer/1c9289ca5e9dab0f105a4eaf6664638c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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