-
Notifications
You must be signed in to change notification settings - Fork 621
Paul Jimenez edited this page Aug 31, 2021
·
5 revisions
Use thes zig_inst gist to manage multiple versions of zig in your ~/.local/share/zig/
directory
# Usage: use zig <version>
#
# Loads the specified zig version into the environent
#
use_zig() {
zig_inst -q $1
ZIG_DIR="${HOME}/.local/share/zig/$1"
ZIG_UPDATE="${ZIG_DIR}/zig_update"
if [ ! -f "${ZIG_UPDATE}" ]; then
echo -e "#!/bin/bash\nzig_inst -q -f $1\n" > "${ZIG_UPDATE}"
chmod a+x "${ZIG_UPDATE}"
fi
PATH_add "${ZIG_DIR}"
PATH_add "./zig-cache/bin"
PATH_add "./zig-out/bin"
echo "Using zig $1"
}
This not only adds the correct version of zig to your PATH, but also adds the local output dir (./zig-out/bin
). (./zig-cache/bin
is also added to support older versions of zig)
zig_update
is also added as a command to update the zig master build to the latest (running it on other versions will work, but likely has no effect). Those 4 lines can be omitted if desired.
Very simple:
use zig 0.8.0
...and you're ready to go!