blob: 6f20f5e52e5bfc57bb2c52a152047b469a455e43 (
plain)
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
|
#!/usr/bin/env bash
# general installer for sharkdp's rust based applications
USAGE="Usage: ${0##*/} <app>"
APPS="Apps: bat, hyperfine, hexyl, fd, vivid, pastel, lscolors, diskus"
app=$1
if [[ -z $app || $app == "help" ]]; then
echo $USAGE >&2
echo $APPS >&2
exit 0
fi
if [[ "$app" == "list" ]]; then
echo $USAGE >&2
exit 0
fi
if [ ! "$(which $app)" ]; then
current_version=0.0.0
echo "$app: not installed"
else
current_version=$($app --version | grep -oE "[0-9\.]+")
echo "$app: found $current_version"
fi
latest_version=$(curl -s "https://github.com/sharkdp/${app}/releases/latest" | grep -oE '[0-9]+.[0-9\.]+')
if [ "$2" ]; then
latest_version=$2
fi
if [[ "$current_version" == "$latest_version" ]]; then
echo "$app: up-to-date"
else
echo "$app: new version found $latest_version"
echo "$app: downloading..."
arch="$(uname -m)"
filename="${app}-v${latest_version}-${arch}-unknown-linux-musl"
curl -fsSLo "${filename}.tar.gz" "https://github.com/sharkdp/${app}/releases/download/v${latest_version}/${filename}.tar.gz"
tar -zxvf "${filename}.tar.gz" "${filename}/${app}"
mv "${filename}/${app}" "${HOME}/.local/bin/"
rm -r "${filename}"
rm "${filename}.tar.gz"
fi
|