mirror of https://github.com/tiyn/dotfiles
parent
cc85e466e4
commit
74652652fa
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env 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 "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
||||||
|
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
|
||||||
|
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
|
||||||
|
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||||||
|
*\.tex) textype "$file" ;;
|
||||||
|
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||||||
|
*config.h) 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
|
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||||
|
# I have vim run this file whenever I exit a .tex file.
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
*.tex)
|
||||||
|
file=$(readlink -f "$1")
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
base="${file%.*}"
|
||||||
|
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;;
|
||||||
|
*) printf "Give .tex file as argument.\\n" ;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in new issue