#!/usr/bin/env bash # Coder dotfiles bootstrap — runs via `coder dotfiles` on every workspace start. # Idempotent + merge-safe. Golden owns system tools + starship/mise/eza; this repo # owns personal config only. Safe to run repeatedly. set -euo pipefail DOTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" log(){ printf '[dotfiles] %s\n' "$*"; } # 1) Symlink everything under home/ into $HOME, preserving structure. A real # (non-symlink) file already there is backed up once to .pre-dotfiles. if [ -d "$DOTS/home" ]; then while IFS= read -r -d '' f; do rel="${f#"$DOTS/home/"}" dst="$HOME/$rel" mkdir -p "$(dirname "$dst")" if [ -e "$dst" ] && [ ! -L "$dst" ]; then mv "$dst" "$dst.pre-dotfiles"; fi ln -sfn "$f" "$dst" log "linked ~/$rel" done < <(find "$DOTS/home" -type f -print0) fi # 2) Seed ~/.claude.json so Claude Code skips first-run onboarding (theme + login # wizard). Auth itself comes from the CLAUDE_CODE_OAUTH_TOKEN user-secret env # var — this only marks onboarding complete. Merge-safe: preserves whatever # Claude Code writes there (projects, mcp, etc.). if command -v python3 >/dev/null 2>&1; then python3 - <<'PY' import json, os p = os.path.expanduser("~/.claude.json") try: d = json.load(open(p)) except Exception: d = {} d.setdefault("theme", "dark") d["hasCompletedOnboarding"] = True json.dump(d, open(p, "w"), indent=2) print("[dotfiles] seeded ~/.claude.json (onboarding + theme)") PY fi log "done"