]> git.newer.systems - nvim.git/commitdiff
getcomp
authorTucker Johnson <tucker@newer.systems>
Tue, 25 Feb 2025 22:44:28 +0000 (17:44 -0500)
committerTucker Johnson <tucker@newer.systems>
Tue, 25 Feb 2025 22:44:28 +0000 (17:44 -0500)
scripts/getcomproot [new file with mode: 0755]

diff --git a/scripts/getcomproot b/scripts/getcomproot
new file mode 100755 (executable)
index 0000000..d34a2e4
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# A helper script for LaTeX/groff files used by `compiler` and `opout`.
+# The user can add the root file of a larger project as a comment as below:
+# % root = mainfile.tex
+# And the compiler script will run on that instead of the opened file.
+
+texroot="$(grep -i "^.\+\s*root\s*=\s*\S\+" "$1")"
+texroot="${texroot##*=}"
+texroot="${texroot//[\"\' ]}"
+
+[ -f "$texroot" ] && readlink -f "$texroot" || exit 1