Created
May 10, 2023 06:59
-
-
Save regmicmahesh/652e515e6c2e4891fa77e9af1197147f 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
#!/bin/bash | |
set -e | |
CACHE_FOLDER=~/.cache/cloneitdady | |
CACHE_ORGS=$CACHE_FOLDER/orgs | |
refresh_cache() { | |
gh org list >$CACHE_ORGS | |
for ORG_NAME in $(cat $CACHE_ORGS); do | |
gh repo list $ORG_NAME --json "nameWithOwner" --jq ".[].nameWithOwner" >$CACHE_FOLDER/$ORG_NAME | |
done | |
} | |
clone() { | |
ORG_NAMES=$(cat $CACHE_FOLDER/orgs | fzf) | |
REPO_NAMES=$(cat $CACHE_FOLDER/$ORG_NAMES | fzf -m) | |
for REPO_NAME in $REPO_NAMES; do | |
gh repo clone $REPO_NAME $@ | |
done | |
} | |
if [[ $@ =~ "--refresh" ]]; then | |
refresh_cache | |
else | |
clone $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment