Skip to content

Instantly share code, notes, and snippets.

@millipz
Last active February 9, 2025 14:43
Show Gist options
  • Save millipz/33614ef6f90fa971fec0663bf2a5c4c8 to your computer and use it in GitHub Desktop.
Save millipz/33614ef6f90fa971fec0663bf2a5c4c8 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
trap 'echo "❌ Error on line ${LINENO}. Exiting." >&2' ERR
echo "πŸš€ Starting Bootstrap Setup..."
# 1. Check & Install Xcode Command Line Tools
echo "πŸ” Checking for Xcode Command Line Tools..."
if ! xcode-select -p &>/dev/null; then
echo "⚠️ Xcode Command Line Tools not found. Initiating installation..."
xcode-select --install || { echo "❌ Failed to initiate Xcode Command Line Tools installation."; exit 1; }
echo "⏳ Waiting for Xcode Command Line Tools to install (please confirm the installation prompt)..."
until xcode-select -p &>/dev/null; do
sleep 5
done
echo "βœ… Xcode Command Line Tools installation complete!"
else
echo "βœ… Xcode Command Line Tools are already installed."
fi
# 2. Check & Install Homebrew
echo "πŸ” Checking for Homebrew..."
if ! command -v brew &>/dev/null; then
echo "⚠️ Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || { echo "❌ Failed to install Homebrew."; exit 1; }
echo "βœ… Homebrew installed successfully!"
else
echo "βœ… Homebrew is already installed."
fi
# 3. Check & Install chezmoi
echo "πŸ” Checking for chezmoi..."
if ! command -v chezmoi &>/dev/null; then
echo "⚠️ chezmoi not found. Installing chezmoi via Homebrew..."
brew install chezmoi || { echo "❌ Failed to install chezmoi via Homebrew."; exit 1; }
echo "βœ… chezmoi installed successfully!"
else
echo "βœ… chezmoi is already installed."
fi
# 4. Set Dotfiles Repository URL (public, so no credentials are required)
# Replace the URL below with your public dotfiles repository.
DOTFILES_REPO="https://github.com/millipz/chezmoi.git"
echo "πŸ”„ Using dotfiles repository: $DOTFILES_REPO"
# 5. Initialize and Apply Dotfiles via chezmoi
echo "πŸš€ Initializing and applying dotfiles with chezmoi..."
chezmoi init --apply "$DOTFILES_REPO" || { echo "❌ Failed to initialize and apply dotfiles."; exit 1; }
echo "βœ… Dotfiles applied successfully!"
echo "πŸŽ‰ Bootstrap setup complete! Enjoy your freshly configured machine!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment