-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·103 lines (81 loc) · 2.28 KB
/
install
File metadata and controls
executable file
·103 lines (81 loc) · 2.28 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/zsh
set -e
# --- Xcode Command Line Tools ---
if ! xcode-select -p &>/dev/null; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
echo "Waiting for Xcode CLT installation to complete..."
until xcode-select -p &>/dev/null; do
sleep 5
done
echo "Xcode CLT installed."
fi
# --- Clone dotfiles repo ---
DOTFILES_DIR="$HOME/.dotfiles"
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles repo to $DOTFILES_DIR..."
git clone https://github.com/snappy316/dotfiles.git "$DOTFILES_DIR"
fi
cd "$DOTFILES_DIR"
# --- Homebrew ---
# Installed before dotbot so `brew` is on PATH for the brewfile step
# and all subsequent shell commands (tmux, npm, etc.).
# Always eval shellenv so dotbot subprocesses inherit the full PATH.
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# --- Select profile ---
PROFILES_DIR="profiles"
if [ -n "$1" ]; then
PROFILE="$1"
shift
elif [ -t 0 ]; then
# Interactive — prompt for profile
echo ""
echo "Select a profile:"
echo " 1) work"
echo " 2) personal"
echo ""
printf "Enter choice [1]: "
read -r choice
case "$choice" in
2) PROFILE="personal" ;;
*) PROFILE="work" ;;
esac
else
# Piped (curl | zsh) — default to work
PROFILE="work"
fi
CONFIG="${PROFILES_DIR}/${PROFILE}/install.conf.yaml"
if [ ! -f "$CONFIG" ]; then
echo "Error: profile '$PROFILE' not found ($CONFIG does not exist)."
exit 1
fi
echo "Using profile: $PROFILE"
# --- Brew upgrade preference ---
if [ -t 0 ]; then
printf "Upgrade existing Homebrew packages? [y/N]: "
read -r upgrade_choice
case "$upgrade_choice" in
[yY]*) ;;
*) export HOMEBREW_BUNDLE_NO_UPGRADE=1 ;;
esac
else
# Piped — default to no upgrade
export HOMEBREW_BUNDLE_NO_UPGRADE=1
fi
# --- Init submodules ---
DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"
git submodule sync --quiet --recursive
git submodule update --init --recursive
# --- Run dotbot ---
"${DOTFILES_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" \
-d "${DOTFILES_DIR}" \
--plugin-dir dotbot-brew \
-c "${CONFIG}" \
"$@"