Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·74 lines (64 loc) · 3.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·74 lines (64 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Dotfiles bootstrap — macOS, Apple Silicon, zsh.
# Idempotent; safe to re-run. State is managed by chezmoi (+ mise for tooling).
#
# Three ways to run, all supported:
# - Already cloned (or via Coder, which clones then runs this script):
# ~/.dotfiles/install.sh # uses this script's own dir as the repo
# - Remote one-liner on a fresh machine (self-clones to ~/.dotfiles):
# bash -c "$(curl -fsSL https://raw.githubusercontent.com/simshanith/dotfiles/main/install.sh)"
set -euo pipefail
REPO="${DOTFILES_REPO:-https://github.com/simshanith/dotfiles.git}"
# Locate the repo. Prefer the directory this script lives in — that handles a
# normal clone AND Coder (which clones to its own path, e.g. ~/dotfiles, then
# runs the install script from there). When piped via curl|bash there's no
# script file, so fall back to ~/.dotfiles and self-clone below.
if src="${BASH_SOURCE[0]:-}" && [ -n "$src" ] && [ -f "$src" ]; then
DOTFILES="$(cd "$(dirname "$src")" && pwd)"
else
DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
fi
echo "=== Dotfiles Installation ==="
echo "Source: $DOTFILES"
# 1. Homebrew — GUI apps, shells, terminfo. Its installer also
# pulls in the Xcode Command Line Tools, which is how a truly fresh Mac gets
# `git` for the clone step below.
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
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)"
# 2. Clone the repo if it isn't already present (the curl|bash path). When this
# script was run from a checkout, the repo is obviously already here.
if [ ! -f "$DOTFILES/install.sh" ]; then
echo "Cloning $REPO -> $DOTFILES ..."
command -v git &>/dev/null || xcode-select --install || true
git clone "$REPO" "$DOTFILES"
fi
# 3. Brew packages — shells, GUI casks, terminfo, and tools that need brew's
# macOS integration. The CLI toolchain itself lives in mise (see Brewfile).
echo "Installing Homebrew packages..."
brew bundle --file="$DOTFILES/Brewfile" || true
# 4. mise — standalone install (https://mise.run) to ~/.local/bin/mise, not
# brew, so it self-updates via `mise self-update` and stays off brew's
# upgrade cycle. Skipped when already present.
export PATH="$HOME/.local/bin:$PATH"
if ! command -v mise &>/dev/null; then
echo "Installing mise..."
curl -fsSL https://mise.run | sh
fi
# 5. chezmoi takes over: symlink dotfiles, render templates, run run_once_ scripts.
# Bootstrap chicken-and-egg: chezmoi is in the mise baseline, but that baseline
# (~/.config/mise/conf.d/fresh.toml) isn't symlinked until chezmoi applies. So
# run chezmoi on-demand via `mise exec` for the first apply. First run prompts
# for name/email/work/machine (see .chezmoi.toml.tmpl); sourceDir is recorded
# as $DOTFILES, so this works from any clone location.
eval "$(mise activate bash)"
mise exec chezmoi@latest -- chezmoi init --source="$DOTFILES" --apply
# 6. Now the mise baseline IS in place — install the full toolchain (node, rust,
# starship, chezmoi itself, ...). Subsequent updates: `mise install` / `mise up`.
mise install -y
echo ""
echo "=== Done! ==="
echo "Restart shell: exec zsh"
echo "Verify: chezmoi status (should be empty)"