-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·108 lines (88 loc) · 2.39 KB
/
install.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
set -eu
program_name=$0
usage() {
echo "usage: $program_name [-h]"
echo " -h display help"
}
# global variable that points to dotfiles root directory
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib/message.sh
source "$root/scripts/lib/message.sh"
# shellcheck source=scripts/lib/linker.sh
source "$root/scripts/lib/linker.sh"
# shellcheck source=scripts/lib/header.sh
source "$root/scripts/lib/header.sh"
message "pre" "home directory found at $HOME"
message "pre" "dotfiles found at $root"
while getopts "h" argv; do
case $argv in
*)
usage
exit
;;
esac
done
requirements=(bash zsh tmux vim)
# check the existence of required softwares
for cmd in "${requirements[@]}"; do
if ! hash "$cmd" 2>/dev/null; then
message "pre" "Please install $cmd before using this script" "error"
exit 1
fi
done
# vim
install-vim() {
dotfile "vim" "vimrc"
}
# configurations on different tools
# which are installed by ./start.sh env
install-conf() {
dotfile "conf" "dircolors"
configfile "aria2" "" "conf"
configfile "htop" "" "conf"
configrootfile "curl" ".curlrc"
dotfile "wget" "wgetrc"
}
# wakatime
install-wakatime() {
mkdir "$HOME/.wakatime" &>/dev/null || true
dotfile "wakatime" "wakatime.cfg"
}
# tmux
install-tmux() {
configfile "tmux" "" "tmux"
configfile "tmuxs" "" "tmux"
configfile "tmuxp" "" "tmux"
if [ -f "$root/tmux/tmuxp/$HOSTNAME.yaml" ]; then
git update-index --assume-unchanged "$root/tmux/tmuxp/main.yaml"
rm "$root/tmux/tmuxp/main.yaml"
ln -s "$HOSTNAME.yaml" "$root/tmux/tmuxp/main.yaml"
fi
message "tmux" "installing tmux plugins"
if [ ! -d "$HOME/.local/share/tmux/plugins/tpm" ]; then
mkdir -p ~/.local/share/tmux/plugins
git clone https://github.com/tmux-plugins/tpm ~/.local/share/tmux/plugins/tpm
fi
"$HOME/.local/share/tmux/plugins/tpm/bin/install_plugins"
}
# bin
install-bin() {
dotfile "bin" "bin" false
}
# general
install-general() {
if [ "$SHELL" != '/bin/zsh' ]; then
message "general" "please change your shell to zsh manually"
fi
}
# calls each module's install function.
modules=(conf tmux wakatime vim bin general)
for module in "${modules[@]}"; do
message "$module" "---"
echo
install-"$module"
echo
message "$module" "---"
echo
done