summaryrefslogtreecommitdiff
path: root/.local/bin/doc_compiler
diff options
context:
space:
mode:
authorJackson Taylor <jackson@jacksontaylor.xyz>2021-02-01 19:04:54 -0500
committerJackson Taylor <jackson@jacksontaylor.xyz>2021-02-01 19:04:54 -0500
commitaa3f11586147f2a9528e59688a6607d386d2b818 (patch)
treee2b26ad9c82fcd1163df4c6acf6a4cce89527cbe /.local/bin/doc_compiler
parent445f6eaeb94d97aa271970b0fdbbb6841dd349a4 (diff)
Add local bin folder
Diffstat (limited to '.local/bin/doc_compiler')
-rwxr-xr-x.local/bin/doc_compiler38
1 files changed, 38 insertions, 0 deletions
diff --git a/.local/bin/doc_compiler b/.local/bin/doc_compiler
new file mode 100755
index 0000000..1ae86bc
--- /dev/null
+++ b/.local/bin/doc_compiler
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# This script will compile or run another finishing operation on a document. I
+# have this script run via vim.
+#
+# Compiles .tex. groff (.mom, .ms), .rmd, .md. Opens .sent files as sent
+# presentations. Runs scripts based on extention or shebang
+
+file=$(readlink -f "$1")
+dir=$(dirname "$file")
+base="${file%.*}"
+
+cd "$dir" || exit
+
+textype() { \
+ command="pdflatex"
+ ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
+ $command --output-directory="$dir" "$base" &&
+ grep -i addbibresource "$file" >/dev/null &&
+ biber --input-directory "$dir" "$base" &&
+ $command --output-directory="$dir" "$base" &&
+ $command --output-directory="$dir" "$base"
+}
+
+case "$file" in
+ *\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
+ *\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
+ *\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
+ *\.[rR]md) Rscript -e "require(rmarkdown); rmarkdown::render('$file', quiet=TRUE)" ;;
+ *\.tex) textype "$file" ;;
+ *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
+ *config.h) sudo make install ;;
+ *\.c) cc "$file" -o "$base" && "$base" ;;
+ *\.py) python "$file" ;;
+ *\.go) go run "$file" ;;
+ *\.sent) setsid sent "$file" 2>/dev/null & ;;
+ *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
+esac