dotfiles

beau's configuration files
git clone https://git.beauhilton.com/dotfiles.git
Log | Files | Refs | README

compiler (1367B)


      1 #!/usr/bin/env sh
      2 
      3 # This script will compile or run another finishing operation on a document. I
      4 # have this script run via vim.
      5 #
      6 # Compiles .tex. groff (.mom, .ms), .rmd, .md.  Opens .sent files as sent
      7 # presentations.  Runs scripts based on extention or shebang
      8 
      9 file=$(readlink -f "$1")
     10 dir=$(dirname "$file")
     11 base="${file%.*}"
     12 
     13 cd "$dir" || exit
     14 
     15 textype() { \
     16 	command="pdflatex"
     17 	( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
     18 	$command --output-directory="$dir" "$base" &&
     19 	grep -i addbibresource "$file" >/dev/null &&
     20 	biber --input-directory "$dir" "$base" &&
     21 	$command --output-directory="$dir" "$base" &&
     22 	$command --output-directory="$dir" "$base"
     23 	}
     24 
     25 case "$file" in
     26 	*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf > "$base".pdf ;;
     27 	*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf > "$base".pdf ;;
     28 	*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf > "$base".pdf ;;
     29 	*\.rmd) echo "require(rmarkdown); render('$file', output_format = 'all')" | R -q --vanilla ;;
     30 	*\.tex) textype "$file" ;;
     31 	*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
     32 	*config.h) sudo make install ;;
     33         *\.c) cc "$file" -o "$base" && "$base" ;;
     34 	*\.py) python "$file" ;;
     35 	*\.go) go run "$file" ;;
     36 	*\.sent) setsid sent "$file" 2>/dev/null & ;;
     37 	*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
     38 esac