-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
use-fish
54 lines (48 loc) · 1.36 KB
/
use-fish
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
#!/usr/bin/env fish
# Usage:
#
# source (curl -sL https://raw.githubusercontent.com/k1LoW/sheer-heart-attack/main/use-fish)
#
# Reference:
# https://github.com/goreleaser/get
set SHA_GOOS linux
set SHA_EXT tar.gz
set SHA_ARCH amd64
if test $(uname -m) = "arm64"
then
set SHA_ARCH arm64
elif test $(uname -m) = "aarch64"
then
set SHA_ARCH arm64
fi
if test (uname -s) = "Darwin"
set SHA_GOOS darwin
set SHA_EXT zip
end
set SHA_RELEASES_URL "https://github.com/k1LoW/sheer-heart-attack/releases"
test -z "$SHA_TMPDIR"; and set SHA_TMPDIR (mktemp -d)
set SHA_ARCHIVE ""$SHA_TMPDIR"sheer-heart-attack."$SHA_EXT""
function last_version
curl -sL -o /dev/null -w '%{url_effective}' ""$SHA_RELEASES_URL"/latest" |
rev |
cut -f1 -d'/'|
rev
end
function download
test -z "$SHA_VERSION"; and set SHA_VERSION (last_version)
test -z "$SHA_VERSION"; and {
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""
end
download
if test $SHA_EXT = 'tar.gz'
tar -xf "$SHA_ARCHIVE" -C "$SHA_TMPDIR"
else if test $SHA_EXT = 'zip'
unzip -qo "$SHA_ARCHIVE" -d "$SHA_TMPDIR"
end
set -x PATH $PATH:"$SHA_TMPDIR"
echo -e '\e[36mYou can use `sheer-heart-attack` command in this session.\e[m'