summaryrefslogtreecommitdiffstats
path: root/.local/bin/compiler
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2019-05-19 20:05:14 -0400
committerLuke Smith <luke@lukesmith.xyz>2019-05-19 20:05:14 -0400
commitc6e69e96421ebf192eb6de537324e269e7bfda78 (patch)
tree47d34a5ff72d65be9a3e2c6aeb55a88da3a6fbd2 /.local/bin/compiler
parentbf8c6b1e20f42a7725d8d919830fdb274596b20f (diff)
downloadeibhear-c6e69e96421ebf192eb6de537324e269e7bfda78.tar.gz
eibhear-c6e69e96421ebf192eb6de537324e269e7bfda78.tar.zst
eibhear-c6e69e96421ebf192eb6de537324e269e7bfda78.zip
massive cleanup
Diffstat (limited to '.local/bin/compiler')
-rwxr-xr-x.local/bin/compiler37
1 files changed, 37 insertions, 0 deletions
diff --git a/.local/bin/compiler b/.local/bin/compiler
new file mode 100755
index 0000000..7d3bf1d
--- /dev/null
+++ b/.local/bin/compiler
@@ -0,0 +1,37 @@
+#!/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 -kejpt -T pdf > "$base".pdf ;;
+ *\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
+ *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
+ *\.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