Skip to content

Instantly share code, notes, and snippets.

@goldcaddy77
Last active February 7, 2026 03:32
Show Gist options
  • Select an option

  • Save goldcaddy77/e758f3fa836f36521f8c96aedfc2cec1 to your computer and use it in GitHub Desktop.

Select an option

Save goldcaddy77/e758f3fa836f36521f8c96aedfc2cec1 to your computer and use it in GitHub Desktop.
All-in-one Mac setup script for private dotfiles repo
#!/bin/bash
# Minimal Mac Setup Bootstrap
# This script is synced to: https://gist.github.com/goldcaddy77/e758f3fa836f36521f8c96aedfc2cec1
set -e
DOTFILES_REPO="goldcaddy77/dotfiles"
DOTFILES_PATH="$HOME/code/goldcaddy77/dotfiles"
echo "🦞 Mac Setup Bootstrap"
# Install Homebrew
if ! command -v brew &> /dev/null; then
echo "β†’ Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
[[ -f /opt/homebrew/bin/brew ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
else
echo "βœ“ Homebrew already installed"
fi
# Install GitHub CLI
if ! command -v gh &> /dev/null; then
echo "β†’ Installing GitHub CLI..."
brew install gh
else
echo "βœ“ GitHub CLI already installed"
fi
# Authenticate with GitHub (sets up SSH keys)
if ! gh auth status &> /dev/null; then
echo "β†’ Authenticating with GitHub (will set up SSH)..."
gh auth login --web --git-protocol ssh
else
echo "βœ“ GitHub authenticated"
fi
# Clone or update dotfiles (gh uses SSH after auth above)
if [[ -d "$DOTFILES_PATH/.git" ]]; then
echo "β†’ Updating dotfiles..."
cd "$DOTFILES_PATH"
# Switch to SSH if currently using HTTPS
CURRENT_URL=$(git remote get-url origin)
if [[ "$CURRENT_URL" == https://* ]]; then
echo "β†’ Switching remote from HTTPS to SSH..."
git remote set-url origin "git@github.com:$DOTFILES_REPO.git"
fi
git pull && cd - >/dev/null
else
echo "β†’ Cloning dotfiles..."
mkdir -p ~/code/goldcaddy77
gh repo clone "$DOTFILES_REPO" "$DOTFILES_PATH"
fi
# Run full setup from dotfiles
echo ""
echo "β†’ Running setup from dotfiles..."
bash "$DOTFILES_PATH/setup_mac.sh"
#!/bin/bash
# Minimal Mac Setup Bootstrap
# Installs prerequisites and runs setup from dotfiles repo
set -e
DOTFILES_REPO="goldcaddy77/dotfiles"
DOTFILES_PATH="$HOME/code/goldcaddy77/dotfiles"
echo "🦞 Mac Setup Bootstrap"
# Install Homebrew
if ! command -v brew &> /dev/null; then
echo "β†’ Installing Homebrew..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
[[ -f /opt/homebrew/bin/brew ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
else
echo "βœ“ Homebrew already installed"
fi
# Install GitHub CLI
if ! command -v gh &> /dev/null; then
echo "β†’ Installing GitHub CLI..."
brew install gh
else
echo "βœ“ GitHub CLI already installed"
fi
# Authenticate with GitHub
if ! gh auth status &> /dev/null; then
echo "β†’ Authenticating with GitHub..."
gh auth login --web
else
echo "βœ“ GitHub authenticated"
fi
# Clone or update dotfiles
if [[ -d "$DOTFILES_PATH/.git" ]]; then
echo "β†’ Updating dotfiles..."
cd "$DOTFILES_PATH" && git pull origin main && cd - >/dev/null
else
echo "β†’ Cloning dotfiles..."
mkdir -p ~/code/goldcaddy77
gh repo clone "$DOTFILES_REPO" "$DOTFILES_PATH"
fi
# Run full setup from dotfiles
echo ""
echo "β†’ Running setup from dotfiles..."
bash "$DOTFILES_PATH/setup_mac.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment