-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
executable file
·87 lines (67 loc) · 2.11 KB
/
bootstrap.sh
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
#!/usr/bin/env bash
set -eou pipefail
function check_reqs() {
local reqs=(
git
zsh
nvim
)
for req in "${reqs[@]}"; do
if ! command -v "$req"; then
echo ">>> ERROR: missing requirement: $req"
echo ">>> please install and re-run the script again" && exit 1
fi
done
}
function setup_default_exports() {
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export EDITOR=nvim
export ZDOTDIR="$HOME/.config/zsh"
export DOTBARE_DIR="$HOME/.dtf.git"
export DOTBARE_TREE="$HOME"
export DOTBARE_INSTALL_PREFIX="$XDG_DATA_HOME/zsh/plugins/dotbare"
export TPM_DIR="$XDG_DATA_HOME/tmux/plugins/tpm"
}
function setup_xdg() {
mkdir -p "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" \
"$XDG_CACHE_HOME" "$XDG_STATE_HOME"
}
function setup_dotfiles() {
check_reqs
setup_default_exports
setup_xdg
echo "Fetching dependencies.."
if [ ! -d "$DOTBARE_INSTALL_PREFIX" ]; then
git clone --depth=1 https://github.com/kazhala/dotbare "$DOTBARE_INSTALL_PREFIX"
fi
if [ ! -d "$HOME/.dtf.git" ]; then
"$DOTBARE_INSTALL_PREFIX/dotbare" finit -u https://github.com/kylo252/dotfiles.git
ln -sf "$XDG_CONFIG_HOME/git/hooks/dots_post_commit" "$DOTBARE_DIR/hooks/pre-push"
chmod +x "$DOTBARE_DIR/hooks/pre-push"
fi
local znap_dir="$XDG_DATA_HOME/zsh/plugins/znap"
if [ ! -d "$znap_dir" ]; then
echo 'setting up zsh ...'
git clone --depth=1 https://github.com/marlonrichert/zsh-snap "$znap_dir"
zsh -c "source $ZDOTDIR/plugins.zsh"
fi
if [ ! -d "$XDG_DATA_HOME/fzf" ]; then
git clone --depth=1 https://github.com/junegunn/fzf "$XDG_DATA_HOME/fzf"
fi
echo "setting up fzf .."
"$XDG_DATA_HOME/fzf/install" --all --xdg --completion --no-update-rc
echo "setting up tmux.."
if [ ! -d "$TPM_DIR" ]; then
git clone --depth=1 https://github.com/tmux-plugins/tpm "$TPM_DIR"
fi
echo "setup complete!"
}
setup_dotfiles
unset -f check_reqs
unset -f setup_dotfiles
unset -f setup_default_exports