summaryrefslogtreecommitdiffstats
path: root/.scripts/compiler
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-07-25 13:45:05 -0400
committerLuke Smith <luke@lukesmith.xyz>2018-07-25 13:45:05 -0400
commit595ae287e1884105e3fdf30d87989cb3e54fcb2d (patch)
tree7a4c99cf64ecbd318fd33ce38852eba0d6c29084 /.scripts/compiler
parent5fc6f7459844c6c378c303d380eb52a5945c27fa (diff)
downloadeibhear-595ae287e1884105e3fdf30d87989cb3e54fcb2d.tar.gz
eibhear-595ae287e1884105e3fdf30d87989cb3e54fcb2d.tar.zst
eibhear-595ae287e1884105e3fdf30d87989cb3e54fcb2d.zip
cleanup, script now runable anywhere
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