Link to search your gists. Uses @me to refer to itself in the gist search query.
https://gist.github.com/search?q=user%3A%40me&ref=searchresults
https://docs.github.com/en/search-github/searching-on-github/searching-gists
#! /bin/bash | |
set -x | |
set -e | |
# generate your token from https://github.com/settings/tokens and save it into gist-token.txt | |
token=$(cat gist-token.txt) | |
function cloneOrPull() { | |
page=$1 | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $token" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/gists?per_page=100&page=$page" > gists-${page}.json | |
jq -c -r '.[]' gists-${page}.json | while read gist; do | |
id=$(echo $gist | jq -r '.id') | |
if [ -d "$id" ]; then | |
cd $id; git pull > /dev/null 2>&1; cd .. | |
else | |
git clone $(echo $gist | jq -r '.git_pull_url') > /dev/null 2>&1 | |
fi | |
done | |
jq length gists-${page}.json | |
} | |
page=1 | |
count=0 | |
while true; do | |
length=$(cloneOrPull $page) | |
count=$(($count + $length)) | |
if [ $length -lt 100 ]; then | |
break | |
fi | |
page=$(($page + 1)) | |
done | |
echo total $count gists |
Link to search your gists. Uses @me to refer to itself in the gist search query.
https://gist.github.com/search?q=user%3A%40me&ref=searchresults
https://docs.github.com/en/search-github/searching-on-github/searching-gists
Works, thanks.