Eric Bower
·
2026-09-08
1#!/usr/bin/env bash
2set -euo pipefail
3
4if ! command -v zig >/dev/null 2>&1; then
5 echo "error: zig not found in PATH" >&2
6 exit 1
7fi
8
9if ! command -v ctags >/dev/null 2>&1; then
10 echo "error: ctags not found in PATH" >&2
11 exit 1
12fi
13
14std_dir="$(zig env | grep '\.std_dir' | sed -E 's/.*"([^"]+)".*/\1/')"
15
16if [[ -z "${std_dir}" || ! -d "${std_dir}" ]]; then
17 echo "error: could not locate zig std directory" >&2
18 exit 1
19fi
20
21cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/tags"
22target="${cache_dir}/zig_std.tags"
23
24mkdir -p "${cache_dir}"
25
26echo "Generating Zig standard library tags from ${std_dir}..."
27ctags -f "${target}" "${std_dir}"
28echo "Saved tags to ${target} ($(du -h "${target}" | cut -f1))"