forked from helium777/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
40 lines (34 loc) · 999 Bytes
/
Copy pathbootstrap.sh
File metadata and controls
40 lines (34 loc) · 999 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
command_exists() {
# we will add ~/.local/bin to PATH later
PATH="$HOME/.local/bin:$PATH"
command -v "$1" >/dev/null
}
# check if pre-requisites are installed
PREREQS=(
"lua"
"eza"
"bat"
)
for cmd in "${PREREQS[@]}"; do
if ! command_exists "$cmd"; then
echo "Pre-requisite $cmd is not installed. Please install it and run the script again."
exit 1
fi
done
# clone into ~/.local/share/dotfiles
mkdir -p ~/.local/share
cd ~/.local/share
[[ -d dotfiles ]] || git clone https://github.com/HawkW1027/dotfiles.git
cd dotfiles
# update repo
git pull
# source init.zsh in the beginning of .zshrc
if ! grep -q "source ~/.local/share/dotfiles/zsh/init.zsh" ~/.zshrc; then
temp_zshrc=$(mktemp)
printf "source ~/.local/share/dotfiles/zsh/init.zsh\n\n" > "$temp_zshrc"
[[ -f ~/.zshrc ]] && cat ~/.zshrc >> "$temp_zshrc"
mv "$temp_zshrc" ~/.zshrc
fi
echo "Bootstrapped and updated dotfiles successfully!"