summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/compiler16
-rwxr-xr-x.local/bin/getcomproot12
-rwxr-xr-x.local/bin/opout2
3 files changed, 21 insertions, 9 deletions
diff --git a/.local/bin/compiler b/.local/bin/compiler
index 85a0c58..6e28cd0 100755
--- a/.local/bin/compiler
+++ b/.local/bin/compiler
@@ -17,15 +17,15 @@ ext="${file##*.}"
cd "$dir" || exit 1
textype() { \
+ textarget="$(getcomproot "$file" || echo "$file")"
+ echo "$textarget"
command="pdflatex"
- texroot=$(grep -Poi "^ *% *\! *tex root *= *\w+(?:\.\w*)?" "$file" | cut -d "=" -f 2 | tr -d "[:blank:]")
- [ -n "$texroot" ] && base=$texroot && echo "Compiling from TeX root: $texroot"
- ( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
- $command --output-directory="$dir" "$base" &&
- grep -qi addbibresource "$file" &&
- biber --input-directory "$dir" "$base" &&
- $command --output-directory="$dir" "$base" &&
- $command --output-directory="$dir" "$base"
+ ( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
+ $command --output-directory="${textarget%/*}" "${textarget%.*}"
+ grep -qi addbibresource "$textarget" &&
+ biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
+ $command --output-directory="${textarget%/*}" "${textarget%.*}" &&
+ $command --output-directory="${textarget%/*}" "${textarget%.*}"
}
case "$ext" in
diff --git a/.local/bin/getcomproot b/.local/bin/getcomproot
new file mode 100755
index 0000000..d34a2e4
--- /dev/null
+++ b/.local/bin/getcomproot
@@ -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
diff --git a/.local/bin/opout b/.local/bin/opout
index faf6575..8890861 100755
--- a/.local/bin/opout
+++ b/.local/bin/opout
@@ -7,7 +7,7 @@
basename="${1%.*}"
case "${*}" in
- *.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid -f xdg-open "$basename".pdf >/dev/null 2>&1 ;;
+ *.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) target="$(getcomproot "$1" || echo "$1")" ; setsid -f xdg-open "${target%.*}".pdf >/dev/null 2>&1 ;;
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
esac