Skip to main content
The setup script automates the configuration of your macOS development environment by installing essential tools, configuring system settings, and symlinking dotfiles.

What Gets Configured

The setup process handles:
  • Config Repository: Clones your dotfiles to ~/.config
  • Dotfile Symlinking: Links configuration files to your home directory
  • Xcode Command Line Tools: Installs developer tools required by Homebrew
  • Touch ID for sudo: Enables biometric authentication for sudo commands
  • Homebrew: Installs the package manager for macOS
  • Homebrew Bundle: Installs all packages, casks, and Mac App Store apps

Running the Setup

The setup script can be run with a single command:
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/mac9sb/config/main/setup.sh)"
The script is idempotent - you can run it multiple times safely. It checks for existing installations and skips steps that are already complete.

Setup Flow

1

macOS Validation

The script verifies it’s running on macOS by checking uname -s.
[ "$(uname -s)" = "Darwin" ] || die "This script is macOS-only."
2

Config Repository

Clones https://github.com/mac9sb/config.git to ~/.config if not already present.
if [ -d "$CONFIG_DIR/.git" ]; then
  log "Config repo: already present at $CONFIG_DIR"
  return 0
fi

log "Cloning config repo into $CONFIG_DIR"
git clone "$CONFIG_REPO_URL" "$CONFIG_DIR"
3

Symlink Dotfiles

Creates symbolic links from ~/.config/.* files to your home directory.
for file in "$CONFIG_DIR"/.*; do
  [ -f "$file" ] || continue
  filename="$(basename "$file")"
  case "$filename" in
  . | ..) continue ;;
  .git) continue ;;
  *) ln -sf "$file" "$HOME/$filename" ;;
  esac
done
4

Xcode Command Line Tools

Installs Xcode CLT if not present. This step may require user interaction.
if xcode-select -p >/dev/null 2>&1; then
  log "Xcode Command Line Tools: already installed"
  return 0
fi

log "Installing Xcode Command Line Tools (a GUI prompt will appear)..."
xcode-select --install >/dev/null 2>&1 || true
log "Re-run this script after the CLT installation finishes."
exit 0
5

Touch ID Configuration

Enables Touch ID for sudo authentication using /etc/pam.d/sudo_local.See Touch ID for sudo for details.
6

Homebrew Installation

Installs Homebrew if not already present.See Homebrew Setup for details.
7

Homebrew Bundle

Installs all packages, casks, and Mac App Store apps from the Brewfile.See Homebrew Bundle for the complete list.

Logging

The script uses structured logging with timestamps and log levels:
log() {
  level="${2:-INFO}"
  printf "%s [%s] %s\n" "$(date +'%Y-%m-%dT%H:%M:%S%z')" "$level" "$1"
}
Log levels used:
  • INFO - Normal operation messages
  • WARN - Non-fatal issues
  • ERROR - Fatal errors that stop execution
The script uses set -eu to fail fast on errors and undefined variables, ensuring setup problems are caught early.

Error Handling

The script includes helper functions for error handling:
die() {
  log "$*" "ERROR"
  exit 1
}

warn() {
  log "$*" "WARN"
}
Fatal errors (like running on non-macOS systems) use die(), while non-critical failures (like Touch ID configuration issues) use warn() and continue.

Build docs developers (and LLMs) love