Created
August 20, 2023 05:24
-
-
Save burritoOverflow/478db482ac7d6d0acad67aa9c3e7c78f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
if ! command -v gh &> /dev/null || ! command -v jq &> /dev/null | |
then | |
echo "requires both gh and jq" | |
exit 1 | |
fi | |
if [ -z "$1" ] | |
then | |
echo "./cloneallrepos.sh githubusername" | |
exit 2 | |
fi | |
USER=$1 | |
echo "cloning repos for user: $USER" | |
REPOS=`gh api users/$USER/repos --paginate --jq '.[].ssh_url' | sort` | |
OUTDIR=$USER"githubrepos" | |
mkdir -p $OUTDIR | |
pushd `pwd` | |
cd $OUTDIR | |
while IFS= read -r line; do | |
echo "cloning $line" | |
git clone $line | |
done <<< "$REPOS" | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment