-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvim-updater
executable file
·98 lines (85 loc) · 3.06 KB
/
nvim-updater
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
#!/usr/bin/env sh
normal() {
if command -v nvim /dev/null 2>&1; then
ins_ver=$(nvim --version | sed -n 1p | grep -E -o 'v(.*)')
latest_version=$(curl -Ls -o /dev/null -w %\{url_effective\} https://github.com/neovim/neovim/releases/latest | rev | cut -f 1 -d '/' | rev)
echo "Installed version = $ins_ver"
echo "Latest version = $latest_version"
echo 'Do you want to install ? (y/N)'
read -r choice
if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
rm -rf "$HOME/opt/nvim-linux64"
tar -C "$HOME/opt" -xzf nvim-linux64.tar.gz
rm -rf nvim-linux64.tar.gz
rm -rf "$HOME/opt/bin/nvim"
ln -s "$HOME/opt/nvim-linux64/bin/nvim" "$HOME/opt/bin/"
fi
else
echo 'Do you want to install ? (y/N)'
read -r choice
if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz
rm -rf "$HOME/opt/nvim-linux64"
tar -C "$HOME/opt" -xzf nvim-linux64.tar.gz
rm -rf nvim-linux64.tar.gz
rm -rf "$HOME/opt/bin/nvim"
ln -s "$HOME/opt/nvim-linux64/bin/nvim" "$HOME/opt/bin/"
fi
fi
}
appimage() {
if command -v nvim /dev/null 2>&1; then
ins_ver=$(nvim --version | sed -n 1p | grep -E -o 'v(.*)')
latest_version=$(curl -Ls -o /dev/null -w %\{url_effective\} \
https://github.com/neovim/neovim-releases/releases/latest | rev | cut -f 1 -d '/' | rev)
echo "Installed version = $ins_ver"
echo "Latest version = $latest_version"
echo 'Do you want to install ? (y/N)'
read -r choice
if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
rm -f "$HOME/opt/nvim.appimage"
curl -LO https://github.com/neovim/neovim-releases/releases/latest/download/nvim.appimage \
-o "$HOME/opt/nvim.appimage"
chmod u+x "$HOME/opt/nvim.appimage"
cd "$HOME/opt/" || exit
rm -rf "squashfs-root"
./nvim.appimage --appimage-extract
fi
else
echo 'Do you want to install ? (y/N)'
read -r choice
if [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
curl -LO https://github.com/neovim/neovim-releases/releases/latest/download/nvim.appimage \
-o "$HOME/opt/nvim.appimage"
chmod u+x "$HOME/opt/nvim.appimage"
cd "$HOME/opt/" || exit
./nvim.appimage --appimage-extract
fi
fi
}
# parse argv variables
if [ -n "$1" ]; then
:
else
echo "Choose a variant, either --appimage(unsupported/old glibc) or --main(supported/main)"
fi
while [ "$#" -gt 0 ]; do
case "$1" in
--appimage)
appimage
shift 1
;;
--main)
normal
shift 1
;;
-h | --help)
usage
exit
;;
*)
normal
;;
esac
done