summaryrefslogtreecommitdiffstats
path: root/.scripts/compiler
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/compiler')
-rwxr-xr-x.scripts/compiler34
1 files changed, 17 insertions, 17 deletions
diff --git a/.scripts/compiler b/.scripts/compiler
index c6fc8b8..73ce5bc 100755
--- a/.scripts/compiler
+++ b/.scripts/compiler
@@ -1,32 +1,32 @@
#!/bin/bash
-# This is a compilation handler, so to speak, which I have vim run.
+# This script will compile or run another finishing operation on a document. I
+# have this script run via vim.
#
-# It compiles a document to pdf
-#
-# If you put the sequence `xelatex` somewhere in the first 5 lines of a .tex
-# file, it will be compiled with `xelatex` rather than `pdflatex`.
-#
-# If it detects an `addbibresource` line, it will run `biber` and perform
-# multiple compiles to get the references correct.
+# tex files: Compiles to pdf, including bibliography if necessary
+# md files: Compiles to pdf via pandoc
+# rmd files: Compiles via R Markdown
+# config.h files: (For suckless utils) recompiles and installs program.
+# all others: run `sent` to show a presentation
file=$(readlink -f "$1")
-ext="${file##*.}"
+dir=$(dirname "$file")
base="${file%.*}"
textype() { \
command="pdflatex"
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
- $command "$base" &&
+ $command --output-directory="$dir" "$base" &&
grep -i addbibresource "$file" &&
- biber "$base" &&
- $command "$base" &&
- $command "$base"
+ biber --input-directory "$dir" "$base" &&
+ $command --output-directory="$dir" "$base" &&
+ $command --output-directory="$dir" "$base"
}
-case "$ext" in
- rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;;
- tex) textype "$file" ;;
- md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
+case "$file" in
+ *\.rmd) echo "require(rmarkdown); render('$file')" | R --vanilla ;;
+ *\.tex) textype "$file" ;;
+ *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
+ *config.h) make && sudo make install ;;
*) sent "$file" 2>/dev/null & ;;
esac