Skip to content

Instantly share code, notes, and snippets.

@helgi
Last active August 15, 2026 14:33
Show Gist options
  • Select an option

  • Save helgi/1913361d1828e821228f47612cb333e7 to your computer and use it in GitHub Desktop.

Select an option

Save helgi/1913361d1828e821228f47612cb333e7 to your computer and use it in GitHub Desktop.
Dotfiles bootstrap script
#!/usr/bin/env bash
set -euo pipefail
echo "Bootstrapping dotfiles..."
DOTFILES_DIR="$HOME/dotfiles"
if ! command -v brew >/dev/null 2>&1; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if ! command -v git &>/dev/null || ! command -v gh &>/dev/null; then
echo "Installing git and gh via Homebrew..."
HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_HINTS=1 brew install --yes git gh
fi
if ! gh auth status &>/dev/null; then
echo "Authenticating GitHub CLI (visit https://github.com/login/device and enter the code below):"
gh auth login --hostname github.com --git-protocol https --web </dev/null
fi
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning helgi/dotfiles into $DOTFILES_DIR..."
gh repo clone helgi/dotfiles "$DOTFILES_DIR"
else
echo "Dotfiles repo already exists at $DOTFILES_DIR. Pulling latest updates..."
git -C "$DOTFILES_DIR" pull --ff-only
fi
echo "Handing off to install.sh..."
exec "$DOTFILES_DIR/install.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment