Skip to content

Instantly share code, notes, and snippets.

@nektro
Last active November 16, 2023 00:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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