Last active
June 13, 2022 19:54
-
-
Save brighteyed/4ecdf2fa8cddbb877e3b4dcfa403b96f to your computer and use it in GitHub Desktop.
Get random starred repo for github user
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/bash | |
USER=${1:-brighteyed} | |
STARS=$(curl -is "https://api.github.com/users/$USER/starred?per_page=1" | egrep -i '^Link' | egrep -o 'page=[0-9]+' | tail -1 | cut -d= -f2) | |
echo "$STARS starred repos found for $USER" | |
REPO=$(shuf -i1-$STARS -n1) | |
URL=$(curl -s "https://api.github.com/users/$USER/starred?per_page=1&page=$REPO" | jq '.[]|{html_url}' | jq --raw-output '.[]') | |
echo $URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment