-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·75 lines (66 loc) · 1.85 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·75 lines (66 loc) · 1.85 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
75
#!/usr/bin/env bash
# Entry point for a fresh machine.
# Detects OS, installs dependencies, clones the repo, and symlinks configs.
set -euo pipefail
DOTFILES_DIR="${DOTFILES_DIR:-$HOME/.dotfiles}"
REPO="${DOTFILES_REPO:-https://github.com/charsmith/.dotfiles}"
detect_os() {
case "$(uname -s)" in
Darwin) echo "macos" ;;
Linux)
if [[ -r /etc/os-release ]]; then
# shellcheck disable=SC1091
. /etc/os-release
case "${ID:-}${ID_LIKE:-}" in
*ubuntu*|*debian*) echo "ubuntu" ;;
*) echo "unsupported-linux" ;;
esac
else
echo "unsupported-linux"
fi
;;
*) echo "unsupported" ;;
esac
}
OS="$(detect_os)"
# Ensure git is available before attempting to clone
if ! command -v git &>/dev/null; then
echo "git not found — installing..."
case "$OS" in
macos)
# Triggers Xcode Command Line Tools install, which includes git
xcode-select --install 2>/dev/null || true
echo "Follow the Xcode CLT prompt, then re-run bootstrap.sh"
exit 1
;;
ubuntu)
sudo apt-get update -y
sudo apt-get install -y git
;;
*)
echo "Cannot install git on unsupported OS. Install it manually and re-run."
exit 1
;;
esac
fi
# Clone dotfiles first so we can run scripts from the repo
if [[ ! -d "$DOTFILES_DIR" ]]; then
echo "Cloning dotfiles to $DOTFILES_DIR..."
git clone "$REPO" "$DOTFILES_DIR"
else
echo "$DOTFILES_DIR already exists, skipping clone."
fi
case "$OS" in
macos)
bash "$DOTFILES_DIR/scripts/install-deps-macos.sh"
;;
ubuntu)
bash "$DOTFILES_DIR/scripts/install-deps-ubuntu.sh"
;;
*)
echo "Unsupported OS: $OS. Skipping dependency install — symlinks only."
;;
esac
bash "$DOTFILES_DIR/scripts/install-symlinks.sh"
bash "$DOTFILES_DIR/scripts/install-claude.sh"
echo "Bootstrap complete."