clone_repos/clone_repos.sh
2024-08-08 12:28:32 -05:00

27 lines
576 B
Bash
Executable file

#!/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"