-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·103 lines (91 loc) · 2.64 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·103 lines (91 loc) · 2.64 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
#!/usr/bin/env bash
# Bootstrap dotfiles on a fresh machine
# Usage: bash -c "$(curl -fsSL https://raw.githubusercontent.com/memorysaver/dotfiles/main/bootstrap.sh)"
set -euo pipefail
DOTFILES_DIR="$HOME/.dotfiles"
REPO="https://github.com/memorysaver/dotfiles.git"
echo "=== Dotfiles Bootstrap ==="
# --- Detect OS ---
case "$(uname -s)" in
Darwin) OS="macos" ;;
Linux) OS="linux" ;;
*) echo "Unsupported OS: $(uname -s)"; exit 1 ;;
esac
echo "Detected OS: $OS"
# --- Install foundation ---
if [ "$OS" = "macos" ]; then
# Xcode CLI tools
if ! xcode-select -p &>/dev/null; then
echo "Installing Xcode CLI tools (accept the GUI dialog if it appears)..."
xcode-select --install 2>/dev/null || true
until xcode-select -p &>/dev/null; do
sleep 10
done
echo "Xcode CLI tools installed."
fi
# Homebrew
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -x /usr/local/bin/brew ]; then
eval "$(/usr/local/bin/brew shellenv)"
else
echo "ERROR: brew not found after install" >&2
exit 1
fi
fi
else
# Linux: ensure essentials
echo "Updating package lists..."
sudo apt-get update -y
sudo apt-get install -y git curl wget build-essential
fi
# --- Git ---
if ! command -v git &>/dev/null; then
echo "Installing git..."
if [ "$OS" = "macos" ]; then
brew install git
else
sudo apt-get install -y git
fi
fi
# --- Clone dotfiles ---
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles..."
git clone "$REPO" "$DOTFILES_DIR"
else
echo "Dotfiles already at $DOTFILES_DIR"
fi
# --- Zsh (needed before oh-my-zsh) ---
if ! command -v zsh &>/dev/null; then
echo "Installing zsh..."
if [ "$OS" = "macos" ]; then
brew install zsh
else
sudo apt-get install -y zsh
fi
fi
# Set zsh as default shell if it isn't already
if [ "$(basename "$SHELL")" != "zsh" ]; then
echo "Setting zsh as default shell..."
chsh -s "$(command -v zsh)" || echo "WARN: chsh failed; run 'chsh -s $(command -v zsh)' manually later."
fi
# --- Just (task runner) ---
if ! command -v just &>/dev/null; then
echo "Installing just..."
if [ "$OS" = "macos" ]; then
brew install just
else
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
fi
fi
# --- Hand off to just ---
echo ""
echo "=== Running just setup ==="
cd "$DOTFILES_DIR"
just setup
echo ""
echo "=== Bootstrap complete! ==="
echo "Restart your shell or run: exec zsh"