summaryrefslogtreecommitdiff
path: root/setup.fish
blob: 28e6f86f679c9b0f783ad027535abd6f2fcb5e1b (plain) (blame)
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
if test -z $argv[1]
    curl -s https://ziglang.org/download/index.json -o index.json
    or exit 1

    set DLLINK (cat index.json | jq -r '.master ."x86_64-linux" .tarball')
    set SHASUM (cat index.json | jq -r '.master ."x86_64-linux" .shasum')

    rm -f index.json

    set TARBALL (echo $DLLINK  | awk -F '/' '{ print $NF }')
    set ZIGDIR  (echo $TARBALL | sed 's/.tar.xz//')

    if ! test -d $ZIGDIR
        wget -q --show-progress --no-clobber $DLLINK
        and shasum -a 256 -c (echo "$SHASUM  $TARBALL" | psub)
        and tar xf $TARBALL
        or  exit 2
    end
else
    set ZIGDIR $argv[1]

    test -d $ZIGDIR
    or exit 3
end

echo "SETUP $ZIGDIR"
fish_add_path --path (pwd)/$ZIGDIR