From e1515335e8157dbb3206e7d56776e19611443653 Mon Sep 17 00:00:00 2001 From: Nic O'Connor Date: Wed, 8 Jul 2026 10:15:39 -0400 Subject: [PATCH] Self-clone in bootstrap.sh so curl-pipe works; document quick start Piping bootstrap.sh into sh left $0 as a non-path, so SCRIPT_DIR pointed at the caller's cwd and the module scripts couldn't be found (exit 127). When no checkout is present, clone/update the repo into ~/.dotfiles and re-exec from there. Add a Quick start section to the README. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 19 +++++++++++++++++++ bootstrap.sh | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/README.md b/README.md index 566381c..f2575e7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,25 @@ Configures fresh VMs (RHEL-family or Debian-family) with a consistent environment. Run `./bootstrap.sh` (or curl-pipe it) to apply everything; each module also runs standalone and is safe to re-run. +## Quick start + +On a fresh box, apply everything with one command: + +```sh +curl -fsSL https://git.nic-oconnor.com/public/dotfiles/raw/branch/main/bootstrap.sh | sh +``` + +When piped like this (no local checkout), `bootstrap.sh` clones the repo to +`~/.dotfiles` and runs from there, so `git` must be installed first. Re-running +the command updates the checkout (`git pull`) and re-applies every module. +Override the destination or source with `DOTFILES_DIR` / `DOTFILES_REPO`. + +Already have a clone? Just run it directly: + +```sh +./bootstrap.sh +``` + ## Modules - `zsh/` — installs zsh + oh-my-zsh, drops a managed `~/.zshrc` diff --git a/bootstrap.sh b/bootstrap.sh index 5de7784..182ec8a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -6,7 +6,28 @@ # (or, from a checked-out clone: ./bootstrap.sh) set -eu +REPO_URL="${DOTFILES_REPO:-https://git.nic-oconnor.com/public/dotfiles.git}" +DOTFILES_DIR="${DOTFILES_DIR:-$HOME/.dotfiles}" + SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" +# When curl-piped into `sh`, there is no checkout on disk: $0 is not a real +# path, so the module scripts alongside this file are missing. Clone (or +# update) the repo, then re-exec bootstrap.sh from the checkout. +if [ ! -f "$SCRIPT_DIR/zsh/install.sh" ]; then + if ! command -v git >/dev/null 2>&1; then + echo "bootstrap: git is required to self-clone; install git first" >&2 + exit 1 + fi + if [ -d "$DOTFILES_DIR/.git" ]; then + echo "bootstrap: updating existing checkout at $DOTFILES_DIR" + git -C "$DOTFILES_DIR" pull --ff-only + else + echo "bootstrap: cloning $REPO_URL into $DOTFILES_DIR" + git clone "$REPO_URL" "$DOTFILES_DIR" + fi + exec "$DOTFILES_DIR/bootstrap.sh" +fi + "$SCRIPT_DIR/zsh/install.sh" "$SCRIPT_DIR/git/install.sh"