Skip to content

Instantly share code, notes, and snippets.

@brighteyed
Last active June 13, 2022 19:54
Show Gist options
  • Save brighteyed/4ecdf2fa8cddbb877e3b4dcfa403b96f to your computer and use it in GitHub Desktop.
Save brighteyed/4ecdf2fa8cddbb877e3b4dcfa403b96f to your computer and use it in GitHub Desktop.
Get random starred repo for github user
#!/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