Skip to content

Instantly share code, notes, and snippets.

@tggreene
Last active December 6, 2025 21:02
Show Gist options
  • Select an option

  • Save tggreene/264d88db0d477ca68c33fab9564efb15 to your computer and use it in GitHub Desktop.

Select an option

Save tggreene/264d88db0d477ca68c33fab9564efb15 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
DOTFILES_REPO="tggreene/dotfiles"
DOTFILES_DIR="${HOME}/.dotfiles"
echo "==> Tim's Mac Bootstrap"
# Xcode CLI tools
if ! xcode-select -p &>/dev/null; then
echo "==> Installing Xcode Command Line Tools..."
xcode-select --install
echo "Press any key when the installation is complete..."
read -n 1
fi
# 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)"
fi
# Add brew to path for this session
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
# Install gh for private repo access
if ! command -v gh &>/dev/null; then
echo "==> Installing GitHub CLI..."
brew install gh
fi
# Authenticate with GitHub if needed
if ! gh auth status &>/dev/null; then
echo "==> Authenticating with GitHub..."
gh auth login
fi
# Clone dotfiles
if [[ ! -d "${DOTFILES_DIR}" ]]; then
echo "==> Cloning dotfiles..."
gh repo clone "${DOTFILES_REPO}" "${DOTFILES_DIR}"
else
echo "==> Dotfiles already exist, pulling latest..."
git -C "${DOTFILES_DIR}" pull
fi
cd "${DOTFILES_DIR}"
# Brewfile
if [[ -f "Brewfile" ]]; then
echo "==> Installing packages from Brewfile..."
brew bundle --file=Brewfile
fi
# Link dotfiles
if [[ -x "./link" ]]; then
echo "==> Linking dotfiles..."
./link
fi
# Post-install
echo "==> Setting up misc..."
# Create common directories
mkdir -p "${HOME}/.local/state/vim"/{backup,swap,undo,info}
mkdir -p "${HOME}/.secrets/gnupg"
# Set shell to zsh if not already
if [[ "${SHELL}" != *"zsh"* ]]; then
echo "==> Changing shell to zsh..."
chsh -s "$(which zsh)"
fi
# Install tool versions via mise
if command -v mise &>/dev/null && [[ -f "${HOME}/.tool-versions" ]]; then
echo "==> Installing tool versions via mise..."
mise install -y
fi
# Install npm globals
if command -v npm &>/dev/null && [[ -f "${DOTFILES_DIR}/npm-globals.txt" ]]; then
echo "==> Installing npm globals..."
xargs npm install -g < "${DOTFILES_DIR}/npm-globals.txt"
fi
# macOS defaults
if [[ -x "${DOTFILES_DIR}/macos-defaults.sh" ]]; then
read -p "==> Apply macOS defaults? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
"${DOTFILES_DIR}/macos-defaults.sh"
fi
fi
echo ""
echo "==> Done! You may need to:"
echo " - Restart your terminal"
echo " - Copy secrets to ~/.secrets/"
echo " - Log into apps (1Password, Dropbox, etc)"
echo " - Import GPG keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment