-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·55 lines (47 loc) · 1.08 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
set -e
function log() {
local level="${1}"
local message="${2}"
local date
date="$(date +'%Y-%m-%d %H:%M:%S')"
if [[ "${level}" == 'INFO' ]]; then
level="[\033[32;1m ${level} \033[0m]"
elif [[ "${level}" == 'WARNING' ]]; then
level="[\033[33;1m${level}\033[0m]"
elif [[ "${level}" == 'ERROR' ]]; then
level="[\033[31;1m ${level} \033[0m]"
fi
echo -e "${level} ${date} - ${message}"
}
function log_info() {
local message="${1}"
log 'INFO' "${message}"
}
function log_warning() {
local message="${1}"
log 'WARNING' "${message}"
}
function log_error() {
local message="${1}"
log 'ERROR' "${message}"
exit 1
}
function install_nvim_config() {
log_info 'Installing nvim configuration...'
local install_path="${HOME}/.config/nvim"
if [[ -d "${install_path}" ]]; then
mkdir -p 'backup'
mv "${install_path}" "backup/nvim.$(date +'%Y%m%d%H%M%S')"
fi
mkdir -p "${HOME}/.config"
pushd nvim >/dev/null
ln -snf "$(pwd)" "${install_path}"
popd >/dev/null
log_info 'Success!'
}
function setup() {
install_nvim_config
log_info 'Completed!'
}
setup "${@}"