#!/usr/bin/env bash source "$(dirname -- "${BASH_SOURCE[0]}")/common.sh" if [[ "$force" == true ]]; then require_typst mkdir -p -- "$repo_root/pdf" exec typst watch --root "$repo_root" "$input" "$output" --open fi build_pdf # Use an absolute path so the viewer also handles names starting with a dash. pdf_path="$(cd -- "$(dirname -- "$output")" && pwd)/$(basename -- "$output")" if command -v xdg-open >/dev/null 2>&1; then exec xdg-open "$pdf_path" elif command -v open >/dev/null 2>&1; then exec open "$pdf_path" else echo "Error: no PDF opener found (xdg-open or open). PDF: $pdf_path" >&2 exit 1 fi