-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·97 lines (71 loc) · 2.19 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
USRLOCAL_BIN=/usr/local/bin
export PATH=$USRLOCAL_BIN:$PATH
INSTALL_HOME=$HOME
[ -n "$SUDO_USER" ] && INSTALL_HOME=/home/$SUDO_USER
cd $(dirname $0)
# https://github.com/BurntSushi/ripgrep
install_ripgrep()
{
local version="12.1.1"
local filename="ripgrep-${version}-x86_64-unknown-linux-musl"
local filetarball="ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz"
local exename="rg"
local bindir=""
if command -v rg >/dev/null 2>&1; then
return 0
fi
[ -d /bin ] && bindir="/bin"
[ -d /usr/bin ] && bindir="/usr/bin"
[ -d /usr/local/bin ] && bindir="/usr/local/bin"
if [ -z "$bindir" ]; then
echo -e "\033[33m- [Warn] install ripgrep failed, bin directory not found\033[0m"
return 1
fi
echo -e "\033[32m- [Info] Install rg to ${bindir}\033[0m"
tar -xf ./tools/${filetarball} \
--strip-components 1 \
--directory=${bindir} \
${filename}/${exename}
chmod +x ${bindir}/${exename}
if ! command -v rg >/dev/null 2>&1; then
echo -e "\033[33m- [Warn] install ripgrep failed\033[0m"
return 1
fi
}
# prepare
if [ -d $INSTALL_HOME/.local/share/nvim/site/autoload ]; then
rm -rf $INSTALL_HOME/.local/share/nvim/site/autoload
fi
if [ -d $INSTALL_HOME/.config/nvim ]; then
rm -rf $INSTALL_HOME/.config/nvim
fi
# copy files
echo -e "\033[32m- [Info] Start to copy files\033[0m"
if [ ! -d $INSTALL_HOME/.local/share/nvim/site ]; then
mkdir -p $INSTALL_HOME/.local/share/nvim/site
fi
cp -rf autoload $INSTALL_HOME/.local/share/nvim/site/
if [ ! -d $INSTALL_HOME/.config ]; then
mkdir -p $INSTALL_HOME/.config
fi
cp -rf nvim $INSTALL_HOME/.config/
# install command
install_ripgrep
# install requirements
echo -e "\033[32m- [Info] Start to install requirements\033[0m"
if ! command -v pip3 >/dev/null 2>&1; then
echo -e "\033[33m- [Err] pip3: command not found\033[0m"
exit 1
fi
is_exist=$(pip3 list 2>/dev/null | grep ^pynvim)
if [ x"$is_exist" == x ]; then
run_cmd="pip3 install pynvim"
$run_cmd
if [ $? -ne 0 ]; then
echo -e "\033[33m- [Err] $run_cmd error\033[0m"
exit 1
fi
fi
echo -e "\033[32m- [Info] Install successfully...\033[0m"
exit 0