-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·117 lines (92 loc) · 2.15 KB
/
install.sh
File metadata and controls
executable file
·117 lines (92 loc) · 2.15 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
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
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
debug_mode='0'
function msg() {
printf '%b\n' "$1" >&2
}
function info() {
msg "\33[36m[>]\33[0m ${1}${2}"
}
function success() {
msg "\33[32m[✔]\33[0m ${1}${2}"
}
function waring() {
msg "\33[33m[!]\33[0m ${1}${2}"
}
function error() {
msg "\33[31m[✘]\33[0m ${1}${2}"
exit 1
}
function debug() {
if [ "$debug_mode" -eq '1' ] && [ "$ret" -gt '1' ]; then
msg "An error occurred in function \"${FUNCNAME[$i+1]}\" on line ${BASH_LINENO[$i+1]}, we're sorry for that."
fi
}
function program_exists() {
local ret='0'
command -v "$1" >/dev/null 2>&1 || { local ret='1'; }
# fail on non-zero return value
if [ "$ret" -ne 0 ]; then
return 1
fi
return 0
}
function variable_must_set() {
if [ -z "$1" ]; then
error "You must have your $1 environmental variable set to continue."
fi
}
function lnif() {
if [ -e "$1" ]; then
ln -sf "$1" "$2"
fi
ret="$?"
debug
}
function check_must_program() {
local program="$1"
program_exists "${program}"
if [[ "$?" -ne 0 ]]; then
error "You must have ${program} installed to continue."
else
success "You have installed ${program}."
fi
}
function check_option_program() {
local program="$1"
program_exists "${program}"
if [[ "$?" -ne 0 ]]; then
waring "Install ${program} to get a better experience."
else
success "You have installed ${program}."
fi
}
function setup_plugs() {
info "Install all vim plugs ..."
local system_shell="$SHELL"
export SHELL='/bin/sh'
# Check(and install) plug.vim
if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
ret="$?"
if [[ "$ret" -eq '0' ]]; then
success "Install plug.vim done."
fi
debug
fi
# Install all plugs
vim +PlugInstall +qall
export SHELL="$system_shell"
ret="$?"
if [[ "$ret" -eq '0' ]]; then
success "Install all vim plugs done."
fi
debug
}
info "Install start ..."
check_must_program "vim"
check_must_program "git"
check_option_program "ag"
check_option_program "ctags"
setup_plugs
info "Install Completed!"