cleanup, script now runable anywhere
This commit is contained in:
parent
5fc6f74598
commit
595ae287e1
1 changed files with 17 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue