dotfiles/install.sh
lollen f08f35b602 dotfiles: initial scaffold for Coder devboxes
install.sh (symlink home/* + merge-seed ~/.claude.json onboarding), gitconfig,
bash_aliases, global gitignore, inputrc, tmux.conf. Golden owns tools+starship;
this owns personal config. Secrets stay in Coder user-secrets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-30 21:05:38 +02:00

41 lines
1.5 KiB
Bash
Executable file

#!/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 <file>.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"