-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
74 lines (61 loc) · 1.25 KB
/
install
File metadata and controls
74 lines (61 loc) · 1.25 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
#!/bin/sh
# Exit on error
set -e
DOTFILES="
.alias
.gitconfig
.zshrc
.pylintrc
"
success () {
echo "\033[32m[OK] \033[0m $1"
}
warn () {
echo "\033[33m[WARN] \033[0m $1"
}
info () {
echo "\033[36m[INFO] \033[0m $1"
}
silence () {
if [[ $DEBUG = 1 ]]; then
"$@"
else
"$@" &>/dev/null
fi
}
confirm () {
message="$1"
read -p "$1 Continue? [yN] " response
if [[ "y" != $response ]]; then
info "Exiting..."
exit 1
fi
}
link_dotfiles () {
for dotfile in $DOTFILES; do
silence ln -sf "$PWD/$dotfile" "$HOME/$dotfile" || warn "Failed to link $dotfile" && \
info "Linked $dotfile"
done
}
# Run all installers
run_installers () {
git ls-tree --name-only -r HEAD | grep install.sh | while read -r installer; do
echo "› ${installer}..."
sh "$installer"
done
}
main () {
confirm "Running this installation will wipe all previous dotfiles."
info "Linking dotfiles"; link_dotfiles
success "Dotfiles installed!"
info "Running installers"; run_installers
success "Custom preferences installed!"
}
if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then
if [[ "debug" = $1 ]]; then
DEBUG=1
else
DEBUG=0
fi
main "$@"
fi