forked from foxx3r/amazing-vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
55 lines (48 loc) · 1.28 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
#!/usr/bin/env bash
# Installation script of amazing-vimrc(Dheison's version)
declare -A DEPENDENCIES=()
DEPENDENCIES['curl']="curl"
DEPENDENCIES['git']="git"
DEPENDENCIES['nvim']="neovim"
function log() {
local type="$1"
local message="$2"
echo "[$type] $message"
}
function check_dependencie() {
local dep="$1"
for p in ${PATH//:/ }; do
if [ -e "$p/$dep" ]; then
return 0;
fi
done
return 1
}
function missing_dependencie() {
local cmd="$1"
local package="${DEPENDENCIES[$cmd]}"
log "ERROR" "Command ${cmd} not found! Install ${package} package to continue."
exit 1
}
log "INFO" "amazing-vimrc setup initialized."
log "INFO" "Checking dependencies..."
for d in ${!DEPENDENCIES[@]}; do
check_dependencie ${d} || missing_dependencie ${d}
done
if [ -d "${HOME}/.config/nvim" ]; then
log "INFO" "Updating installation..."
cd ~/.config/nvim
git pull
else
log "INFO" "Installing for user $(whoami)..."
git clone \
--depth=1 \
--single-branch \
https://github.com/dheison0/amazing-vimrc \
~/.config/nvim
if [ $? != 0 ]; then
log "ERROR" "Failed to clone GitHub repository, try again if you want this."
exit 2
fi
log "INFO" "Installed with success!"
fi