Skip to content

Instantly share code, notes, and snippets.

@regmicmahesh
Created May 10, 2023 06:59
Show Gist options
  • Save regmicmahesh/652e515e6c2e4891fa77e9af1197147f to your computer and use it in GitHub Desktop.
Save regmicmahesh/652e515e6c2e4891fa77e9af1197147f to your computer and use it in GitHub Desktop.
#!/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