-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·94 lines (82 loc) · 2.31 KB
/
bootstrap.sh
File metadata and controls
executable file
·94 lines (82 loc) · 2.31 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
#!/usr/bin/env bash
# Bootstrap dotfiles on a fresh machine
# Usage: curl -fsSL https://raw.githubusercontent.com/memorysaver/dotfiles/main/bootstrap.sh | bash
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..."
xcode-select --install
echo "Press Enter after Xcode CLI tools installation completes..."
read -r
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)"
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)"
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 "$(which zsh)"
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"