Last active
December 15, 2025 20:36
-
-
Save erikj27/388816bb13b79cd47b08fa29432d34b0 to your computer and use it in GitHub Desktop.
WSL Pre-Bootstrap: Install gh CLI before cloning private repos
This file contains hidden or 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 | |
| # pre-bootstrap-wsl.sh | |
| # Installs GitHub CLI and authenticates before cloning private repos | |
| # | |
| # Usage: | |
| # curl -fsSL https://gist.githubusercontent.com/erikj27/YOUR_GIST_ID/raw/pre-bootstrap-wsl.sh | bash | |
| # | |
| # Or manually: | |
| # wget -O - https://gist.githubusercontent.com/erikj27/YOUR_GIST_ID/raw/pre-bootstrap-wsl.sh | bash | |
| set -e | |
| echo "==========================================" | |
| echo " WSL Pre-Bootstrap: GitHub CLI Setup" | |
| echo "==========================================" | |
| echo "" | |
| # Check if gh is already installed | |
| if command -v gh &> /dev/null; then | |
| echo "✓ GitHub CLI already installed ($(gh --version | head -1))" | |
| echo "" | |
| # Check if authenticated | |
| if gh auth status &> /dev/null; then | |
| echo "✓ Already authenticated with GitHub" | |
| echo "" | |
| echo "You're all set! Now run:" | |
| echo " cd ~/workspace/projects" | |
| echo " git clone https://github.com/erikj27/dev-infra.git" | |
| echo " git clone https://github.com/erikj27/workstation.git" | |
| echo " ./dev-infra/scripts/bootstrap-dev.sh" | |
| echo "" | |
| exit 0 | |
| else | |
| echo "⚠ GitHub CLI installed but not authenticated" | |
| echo "" | |
| fi | |
| fi | |
| # Install GitHub CLI | |
| echo "==> Installing GitHub CLI..." | |
| echo "" | |
| sudo mkdir -p -m 755 /etc/apt/keyrings | |
| wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null | |
| sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
| sudo apt update | |
| sudo apt install gh -y | |
| echo "" | |
| echo "✓ GitHub CLI installed successfully" | |
| echo "" | |
| # Authenticate | |
| echo "==> Authenticating with GitHub..." | |
| echo "" | |
| echo "This will open your browser. Choose:" | |
| echo " - GitHub.com" | |
| echo " - HTTPS" | |
| echo " - Login with a web browser" | |
| echo "" | |
| read -p "Press Enter to continue..." | |
| gh auth login | |
| echo "" | |
| echo "==> Configuring git to use gh credentials..." | |
| gh auth setup-git | |
| echo "" | |
| echo "==========================================" | |
| echo " Setup Complete!" | |
| echo "==========================================" | |
| echo "" | |
| echo "Next steps:" | |
| echo " cd ~/workspace/projects" | |
| echo " git clone https://github.com/erikj27/dev-infra.git" | |
| echo " git clone https://github.com/erikj27/workstation.git" | |
| echo " ./dev-infra/scripts/bootstrap-dev.sh" | |
| echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment