Created
December 20, 2011 17:05
-
-
Save sbp/1502325 to your computer and use it in GitHub Desktop.
Mirror a user's gists
This file contains 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
#!/bin/sh | |
GIST_USER=sbp | |
function usage() { | |
echo Usage: $0 [command], where command is one of: | |
echo update - Gets any new gists for user | |
echo pull - Keep existing gists synced with server | |
echo sync - Do an update then a pull | |
} | |
function update() { | |
curl -s https://api.github.com/users/$GIST_USER/gists | | |
python -c 'import sys, json | |
for gist in json.loads(sys.stdin.read()): | |
print gist["id"]' | while read GIST | |
do if [ ! -d $GIST ] | |
then git submodule add git://gist.github.com/$GIST.git | |
echo Created $GIST submodule | |
fi | |
done | |
} | |
function pull() { | |
git submodule foreach git pull | |
} | |
case $1 in | |
update) update;; | |
pull) pull;; | |
sync) update && pull;; | |
*) usage;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment