commit 4b4887ba709ffe6894ca89231a1c43d0c4f185af Author: Blake Ridgway Date: Thu Aug 8 12:28:32 2024 -0500 (feat): Working clone script diff --git a/README.md b/README.md new file mode 100644 index 0000000..37966c3 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Clone Repos + +**Prerequisites** + +- The `gh` command-line tool must be installed, this will allow you to interact directly with Github in your terminal. + diff --git a/clone_repos.sh b/clone_repos.sh new file mode 100755 index 0000000..54f0f3d --- /dev/null +++ b/clone_repos.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Prompt for Github username + +read -p "Enter your Github username: " GITHUB_USER + +# Prompt for directory for cloning + +read -p "Enter the directory where you want to clone the repos: " CLONE_DIR + +# Create the directory if not present +mkdir -p "$CLONE_DIR" + +# Nav to directory +cd "$CLONE_DIR" || exit + +# Fetch all repos + +repos=$(gh repo list "$GITHUB_USER" --limit 100 --json nameWithOwner --jq '.[].nameWithOwner') + +for repo in $repos; do + git clone "git@github.com:$repo.git" + echo "$repo has been cloned" +done + +echo "All repos have been cloned into $CLONE_DIR" +