-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
53 lines (45 loc) · 946 Bytes
/
Copy pathinstall.sh
File metadata and controls
53 lines (45 loc) · 946 Bytes
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
#!/usr/bin/env bash
set -u
APP=jarvim
DOWNLOAD_URL="https://github.com/glepnir/jarvim/releases/latest/download/"
exists() {
command -v "$1" >/dev/null 2>&1
}
download() {
local from=$1
local to=$2
if exists "curl"; then
curl -fLo "$to" "$from"
elif exists 'wget'; then
wget --output-document="$to" "$from"
else
echo 'curl or wget is required'
exit 1
fi
}
try_download() {
local asset=$1
if [ -z "${TMPDIR+x}" ]; then
rm -f $APP
download "$DOWNLOAD_URL/$asset" $APP
else
local temp=${TMPDIR}/jarvim
download "$DOWNLOAD_URL/$asset" "$temp"
mv "$temp" $APP
fi
chmod a+x "$APP"
}
main() {
osname=$(uname -sm)
case "${osname}" in
"Linux x86_64")
try_download "$APP"-x86_64-linux ;;
"Darwin x86_64")
try_download "$APP"-x86_64-darwin ;;
*)
echo "No prebuilt jarvim binary available for ${osname}."
exit 1
;;
esac
}
main