Last active
September 30, 2020 19:53
-
-
Save pfgithub/b79325f4aae1f11d075bc09a7a69b8a7 to your computer and use it in GitHub Desktop.
download the latest zig (fish script oops) (requires: `fish`, `jq`, `curl`, `tar`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
function start_of_line | |
echo -ne "\r"(tput el) | |
end | |
function fail_error | |
echo | |
echo (set_color red)$argv | |
exit | |
end | |
function progress | |
start_of_line | |
echo -n $argv | |
end | |
set os linux | |
set arch x86_64 | |
progress "Downloading versions list..." | |
set json (curl --silent --show-error https://ziglang.org/download/index.json ;or fail_error "Failed to download versions list") | |
set tburl (echo $json | jq -r .master.\"$arch-$os\".tarball) | |
set fname "zig-$os-$arch-"(echo $json | jq -r .master.version) | |
progress "Downloading tarball..." | |
curl --silent --show-error $tburl --output $fname.tar.gz ;or fail_error "Failed to download latest zig" | |
progress "Unzipping..." | |
tar -xf $fname.tar.gz ;or fail_error "Failed to unzip" | |
rm $fname.tar.gz | |
progress (set_color --bold brgreen)"Success!"(set_color normal)" Run "(set_color brblue)"./update.sh"(set_color normal)" to update the zig command." | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment