diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2020-10-03 19:27:15 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2020-10-03 19:27:15 -0400 |
commit | e371d9edd474bcf89cf5d462eaccb8638900b390 (patch) | |
tree | ed07118f5c514a55f23a779a1507640e46fd9ed2 /.local/bin/compiler |
Initial commit
Diffstat (limited to '.local/bin/compiler')
-rwxr-xr-x | .local/bin/compiler | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.local/bin/compiler b/.local/bin/compiler new file mode 100755 index 0000000..5b4f8c4 --- /dev/null +++ b/.local/bin/compiler @@ -0,0 +1,40 @@ +#!/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 -p"$REFERBIB" "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + *\.gd) groffdown "$file" | refer -PS -e "-p$REFERBIB" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + # *\.gd) groffdown "$file" | refer -PS -e "$REFERBIB" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; + *\.mom) refer -PS -e -p"$REFERBIB" "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;; + *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;; + *\.rnw) Rscript -e "knitr::knit2pdf('"$file"')" ;; + *\.tex) textype "$file" ;; + *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; + *config.h) make && 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 |