-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·83 lines (65 loc) · 1.54 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
#!/usr/bin/env bash
config_files=(
".gitconfig"
".gitignore_global"
".inputrc"
".latexmkrc"
)
config_dirs=(
"bat"
"bpython"
"nvim"
)
script_dir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
log() {
printf "\x1b[$1m[$2]\x1b[0m $3\n"
}
ok() {
log "32;1" "info" "$1"
}
info() {
log "37;1" "info" "$1"
}
warn() {
log "33;1" "warn" "$1"
}
error() {
log "31;1" "error" "$1"
}
prompt() {
read -p "$1" -n 1 -r
printf "$REPLY"
}
symlink_install() {
if [ -e "$3/$1" ]; then
warn "$1 already exists at $3"
else
ln -s "$2/$1" "$3/$1"
if [ $? == 0 ]; then
ok "Symlinked $1"
else
error "Failed to symlink $1 (return code: $?)"
fi
fi
}
info "Symlinking from '$script_dir' into '$HOME'..."
reply="$(prompt "Is this the correct directory? ")"
if [[ ! $reply =~ ^[Yy]$ ]]; then
exit 1
fi
printf "\n"
for file in "${config_files[@]}"; do
symlink_install "$file" "$script_dir" "$HOME"
done
for dir in "${config_dirs[@]}"; do
symlink_install "$dir" "$script_dir" "$HOME/.config"
done
symlink_install "fish/aliases.fish" "$script_dir" "$HOME/.config"
symlink_install "fish/config.fish" "$script_dir" "$HOME/.config"
symlink_install "fish/functions/fish_user_key_bindings.fish" "$script_dir" "$HOME/.config"
if [[ -x "brew" ]]; then
info "Installing homebrew packages"
brew install bat delta fd fzf lua-language-server marksman neovim ninja node ripgrep
else
warn "Homebrew not installed, not installing packages"
fi