2018-04-11 00:48:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-07-25 17:45:05 +00:00
|
|
|
# This script will compile or run another finishing operation on a document. I
|
|
|
|
# have this script run via vim.
|
2018-04-11 00:48:45 +00:00
|
|
|
#
|
2018-07-25 17:45:05 +00:00
|
|
|
# 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
|
2018-04-11 00:48:45 +00:00
|
|
|
|
2018-07-30 05:20:04 +00:00
|
|
|
oridir=$(pwd)
|
|
|
|
|
2018-07-24 17:34:38 +00:00
|
|
|
file=$(readlink -f "$1")
|
2018-07-25 17:45:05 +00:00
|
|
|
dir=$(dirname "$file")
|
2018-04-11 00:48:45 +00:00
|
|
|
base="${file%.*}"
|
2018-07-30 05:20:04 +00:00
|
|
|
cd $dir
|
2018-04-11 00:48:45 +00:00
|
|
|
|
2018-07-25 16:14:38 +00:00
|
|
|
textype() { \
|
|
|
|
command="pdflatex"
|
|
|
|
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
2018-07-25 17:45:05 +00:00
|
|
|
$command --output-directory="$dir" "$base" &&
|
2018-07-25 16:14:38 +00:00
|
|
|
grep -i addbibresource "$file" &&
|
2018-07-25 17:45:05 +00:00
|
|
|
biber --input-directory "$dir" "$base" &&
|
|
|
|
$command --output-directory="$dir" "$base" &&
|
|
|
|
$command --output-directory="$dir" "$base"
|
2018-07-25 16:14:38 +00:00
|
|
|
}
|
2018-04-11 00:48:45 +00:00
|
|
|
|
2018-07-25 17:45:05 +00:00
|
|
|
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 ;;
|
2018-07-25 16:14:38 +00:00
|
|
|
*) sent "$file" 2>/dev/null & ;;
|
2018-04-11 00:48:45 +00:00
|
|
|
esac
|
2018-07-30 05:20:04 +00:00
|
|
|
cd $oridir
|