Skip to content

Instantly share code, notes, and snippets.

@aculich
Last active October 2, 2021 06:17
Show Gist options
  • Select an option

  • Save aculich/3eafbba2c60c64651d332c150887c612 to your computer and use it in GitHub Desktop.

Select an option

Save aculich/3eafbba2c60c64651d332c150887c612 to your computer and use it in GitHub Desktop.
List all my currently starred github repos
#!/bin/bash
# List all my currently starred github repos
# username supplied on command line or default to configured github username
ghuser=${1:-$(git config --get github.user)}
if [ -z "$ghuser" ]; then echo -e "Usage: $0 github_username\n\nOptionally: set your github user in ~/.gitconfig"; exit 1; fi
# iterate through all the pages of starred repos
for i in `seq 1 $n`; do curl -s "https://api.github.com/users/$ghuser/starred?access_token=$HOMEBREW_GITHUB_API_TOKEN&per_page=100&page=$i" >> /tmp/starred_${ghuser}-$i.json ; done
# concatenate all pages of json output together
jq -s '.[0]=([.[]]|flatten)|.[0]' /tmp/starred_${ghuser}-*.json > starred_${ghuser}.json
# extract just the url & description
cat starred_${ghuser}.json | jq '[.[] | .description //= "" | {repo:.html_url,desc:.description}]' | tee starred_${ghuser}_brief.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment