-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler
More file actions
executable file
·36 lines (31 loc) · 1.04 KB
/
compiler
File metadata and controls
executable file
·36 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# This script will compile or run another finishing operation on a document. I
# have this script run via vim.
#
# 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
oridir=$(pwd)
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
cd $dir
textype() { \
command="pdflatex"
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -i addbibresource "$file" &&
biber --input-directory "$dir" "$base" &&
$command --output-directory="$dir" "$base" &&
$command --output-directory="$dir" "$base"
}
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
cd $oridir