-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·97 lines (77 loc) · 1.88 KB
/
bootstrap
File metadata and controls
executable file
·97 lines (77 loc) · 1.88 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
#!/usr/bin/env bash
set -e
# https://stackoverflow.com/a/246128
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
REPO="git@github.com:Prioe/dotfiles.git"
_brew_shellenv() {
dirs=(
/home/linuxbrew/.linuxbrew
~/.linuxbrew
/opt/homebrew
)
for dir in "${dirs[@]}"; do
if [ -d "$dir" ]; then
eval "$("$dir"/bin/brew shellenv)"
return
fi
done
}
_install_brew() {
if ! command -v brew &>/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
_brew_shellenv
fi
}
_install_brew_packages() {
brew bundle install --file="$SCRIPT_DIR/Brewfile"
}
_install_dotbot() {
"$SCRIPT_DIR/install"
}
_install_asdf() {
export ASDF_CONFIG_FILE="${XDG_CONFIG_HOME}/asdf/asdfrc"
export ASDF_DATA_DIR="${XDG_DATA_HOME}/asdf"
tool_versions="$SCRIPT_DIR/asdf/tool-versions"
# install asdf plugins referenced in tool-versions
awk '{print $1}' "$tool_versions" | xargs -I {} asdf plugin add {}
asdf install
# shellcheck disable=SC1091
. "$(brew --prefix asdf)/libexec/asdf.sh"
}
_install_rustup() {
export CARGO_HOME="$XDG_DATA_HOME"/cargo
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y
fi
}
_install_nvim() {
zsh -c "nvim --headless +q"
}
_setup_env() {
export XDG_CONFIG_HOME=$HOME/.config
export XDG_CACHE_HOME=$HOME/.cache
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_BUNDLE_NO_LOCK=1
}
_bootstrap() {
cd "$HOME"
_setup_env
_install_brew
_install_brew_packages
_install_dotbot
_install_asdf
_install_rustup
_install_nvim
}
_clone_repo() {
if [ ! -d "$HOME/.dotfiles" ]; then
git clone "$REPO" "$HOME/.dotfiles"
"$HOME/.dotfiles/bootstrap"
exit 0
fi
}
_clone_repo
_bootstrap