-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
use
55 lines (51 loc) · 1.3 KB
/
use
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
#!/bin/sh
# Usege:
#
# source <(curl https://raw.githubusercontent.com/k1LoW/sheer-heart-attack/master/use)
#
# Reference:
# https://github.com/goreleaser/get
SHA_GOOS=linux
SHA_EXT=tar.gz
SHA_ARCH=amd64
if test $(uname -m) = "arm64"
then
SHA_ARCH=arm64
elif test $(uname -m) = "aarch64"
then
SHA_ARCH=arm64
fi
if test $(uname -s) = "Darwin"
then
SHA_GOOS=darwin
SHA_EXT=zip
fi
SHA_RELEASES_URL="https://github.com/k1LoW/sheer-heart-attack/releases"
test -z "$SHA_TMPDIR" && SHA_TMPDIR="$(mktemp -d)"
SHA_ARCHIVE="${SHA_TMPDIR}sheer-heart-attack.${SHA_EXT}"
last_version() {
curl -sL -o /dev/null -w %{url_effective} "$SHA_RELEASES_URL/latest" |
rev |
cut -f1 -d'/'|
rev
}
download() {
test -z "$SHA_VERSION" && SHA_VERSION="$(last_version)"
test -z "$SHA_VERSION" && {
echo "Unable to get sheer-heart-attack version." >&2
exit 1
}
rm -f "$SHA_ARCHIVE"
curl -s -L -o "$SHA_ARCHIVE" \
"${SHA_RELEASES_URL}/download/${SHA_VERSION}/sheer-heart-attack_${SHA_VERSION}_${SHA_GOOS}_${SHA_ARCH}.${SHA_EXT}"
}
download
if test ${SHA_EXT} = "tar.gz"
then
tar -xf "$SHA_ARCHIVE" -C "$SHA_TMPDIR"
elif test ${SHA_EXT} = "zip"
then
unzip -qo "$SHA_ARCHIVE" -d "$SHA_TMPDIR"
fi
export PATH=${SHA_TMPDIR}:$PATH
echo -e '\e[36mYou can use `sheer-heart-attack` command in this session.\e[m'