Skip to content

Instantly share code, notes, and snippets.

@nektro
Last active August 17, 2024 13:29
Show Gist options
  • Save nektro/3c704a2e117b3e33b576ee5d6f7f7107 to your computer and use it in GitHub Desktop.
Save nektro/3c704a2e117b3e33b576ee5d6f7f7107 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
arch=$(uname -m)
os=$(uname -s | tr '[:upper:]' '[:lower:]')
double="$arch-$os"
if [[ $1 == *"dev"* ]]; then
wget -q --show-progress https://ziglang.org/builds/zig-linux-x86_64-$1.tar.xz
else
curl -s https://ziglang.org/download/index.json | jq ".\"$1\"" | jq --raw-output ".\"$double\".tarball" | wget -q --show-progress -i -
fi
file=$(ls | grep '.tar.xz')
tar -xf $file
folder=$file
folder=${folder%.*}
folder=${folder%.*}
rm $file
rm -fr ~/.local/lib/zig
rm -f ~/.local/bin/zig
mv $folder ~/.local/lib/zig
ln -s ~/.local/lib/zig/zig ~/.local/bin
echo
echo "Updated Zig to $folder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment