Created
April 1, 2024 11:51
-
-
Save johanhammar/6f68441b86e2cb584055b03896c1894a to your computer and use it in GitHub Desktop.
Clone GitHub repositories
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 fzf &> /dev/null | |
then | |
echo "Fzf could not be found. See https://github.com/junegunn/fzf" | |
exit 1 | |
fi | |
if ! command -v jq &> /dev/null | |
then | |
echo "Jq could not be found. See https://github.com/jqlang/jq" | |
exit 1 | |
fi | |
if ! command -v gh &> /dev/null | |
then | |
echo "Gh could not be found. See https://cli.github.com/" | |
exit 1 | |
fi | |
if [[ -z "${GITHUB_ACCESS_TOKEN}" ]]; then | |
echo "Must set GITHUB_ACCESS_TOKEN" | |
exit 1 | |
fi | |
REPO_URL=$(gh repo list --limit 500 --json name,sshUrl | jq -r '.[] | [.name, .sshUrl] | join(" : ")' | fzf --prompt ' ' --header="Select repository to clone or use CTRL-C to cancel" --bind 'enter:execute(echo {3})+abort') | |
git clone $REPO_URL | |
unset REPO_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment