-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
Β·139 lines (118 loc) Β· 4.81 KB
/
bootstrap.sh
File metadata and controls
executable file
Β·139 lines (118 loc) Β· 4.81 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -e
DOTFILES_REPO="https://github.com/yslib/dotfiles.git"
DOTFILES_DIR="$(pwd)/dotfiles"
is_windows() {
[[ "$OSTYPE" == "msys" || "$OSTYPE" == "mingw"* || "$OSTYPE" == "cygwin" ]]
}
is_arch_linux() {
[ -f /etc/arch-release ]
}
# Parse Archfile and install packages with pacman/paru
install_arch_packages() {
local archfile="$1"
local section=""
local pacman_pkgs=()
local aur_pkgs=()
while IFS= read -r line || [[ -n "$line" ]]; do
line="${line%%#*}"
line="${line#"${line%%[![:space:]]*}"}"
line="${line%"${line##*[![:space:]]}"}"
[[ -z "$line" ]] && continue
if [[ "$line" == "[pacman]" ]]; then
section="pacman"
elif [[ "$line" == "[aur]" ]]; then
section="aur"
elif [[ "$section" == "pacman" ]]; then
pacman_pkgs+=("$line")
elif [[ "$section" == "aur" ]]; then
aur_pkgs+=("$line")
fi
done < "$archfile"
if [ ${#pacman_pkgs[@]} -gt 0 ]; then
echo "π¦ Installing pacman packages..."
sudo pacman -S --needed --noconfirm "${pacman_pkgs[@]}"
fi
if [ ${#aur_pkgs[@]} -gt 0 ]; then
echo "π¦ Installing AUR packages via paru..."
paru -S --needed --noconfirm "${aur_pkgs[@]}"
fi
}
echo "π Starting Bootstrap..."
# ββ 0. Clone repo if not already inside one βββββββββββββββββββββ
# If run via `curl | bash`, we're not in the repo yet β clone it.
# If run via `./bootstrap.sh` from the repo, skip cloning.
if [ -f "$(dirname "${BASH_SOURCE[0]}")/Brewfile" ]; then
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo "π Running from existing repo at $SCRIPT_DIR"
else
if [ -d "$DOTFILES_DIR/.git" ]; then
echo "π Dotfiles repo already exists at $DOTFILES_DIR, pulling latest..."
git -C "$DOTFILES_DIR" pull --rebase
else
echo "π₯ Cloning dotfiles repo to $DOTFILES_DIR..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
SCRIPT_DIR="$DOTFILES_DIR"
fi
mkdir -p "$HOME/.local/bin"
mkdir -p "$HOME/.config"
# ββ 1. Install packages βββββββββββββββββββββββββββββββββββββββββ
if is_windows; then
echo "πͺ On Windows (Git Bash), using Scoop..."
if ! command -v scoop &>/dev/null; then
echo "β οΈ Scoop not found. Please run bootstrap.ps1 first, or install scoop manually."
exit 1
fi
scoop bucket add extras 2>/dev/null || true
scoop bucket add nerd-fonts 2>/dev/null || true
echo "πΊ Installing packages with Scoop..."
scoop import "$SCRIPT_DIR/Scoopfile.json"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "π On macOS, Installing Homebrew..."
if command -v brew &>/dev/null; then
echo "β
Homebrew already exists, skip installation."
else
export NONINTERACTIVE=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval "$(brew shellenv)"
echo "πΊ Installing packages with Homebrew..."
brew bundle --file="$SCRIPT_DIR/Brewfile" --verbose
elif is_arch_linux; then
echo "π§ On Arch Linux, using pacman + paru..."
# Install paru (AUR helper) if not present
if ! command -v paru &>/dev/null; then
echo "π₯ Installing paru..."
sudo pacman -S --needed --noconfirm base-devel git
PARU_TMPDIR=$(mktemp -d)
git clone https://aur.archlinux.org/paru.git "$PARU_TMPDIR/paru"
(cd "$PARU_TMPDIR/paru" && makepkg -si --noconfirm)
rm -rf "$PARU_TMPDIR"
else
echo "β
paru already installed, skip."
fi
install_arch_packages "$SCRIPT_DIR/Archfile"
else
echo "π§ On Linux, Installing Homebrew..."
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
echo "β
Homebrew already exists, skip installation."
else
export NONINTERACTIVE=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo "πΊ Installing packages with Homebrew..."
brew bundle --file="$SCRIPT_DIR/Brewfile" --verbose
fi
echo "π Setting up Neovim plugins..."
"$SCRIPT_DIR/scripts/setup_nvim_plugin.sh"
# ββ 2. Setup tools and link configs βββββββββββββββββββββββββββββ
if is_windows; then
# Symlinks are handled by bootstrap.ps1 (needs admin token)
echo "β
Package installation complete!"
else
"$SCRIPT_DIR/scripts/install_oh_my_zsh.sh"
"$SCRIPT_DIR/scripts/link_config.sh"
echo "Setup complete! Please restart your terminal to apply changes. \n(Manually change your shell to zsh if you haven't already. Run 'chsh -s $(which zsh)')"
fi