mirror of https://github.com/tiyn/dotfiles
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
5 years ago
|
#!/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
|
||
5 years ago
|
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
|
||
5 years ago
|
|
||
|
file=$(readlink -f "$1")
|
||
|
dir=$(dirname "$file")
|
||
|
base="${file%.*}"
|
||
3 years ago
|
basenodir="${1%.*}"
|
||
5 years ago
|
|
||
|
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" &&
|
||
3 years ago
|
makeglossaries "$basenodir" &&
|
||
5 years ago
|
$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 ;;
|
||
4 years ago
|
*\.m) octave -qW "$file" ;;
|
||
5 years ago
|
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||
|
*config.h) sudo make install ;;
|
||
3 years ago
|
*\.tex) textype "$file" ;;
|
||
3 years ago
|
*\.java) java "$file" ;;
|
||
4 years ago
|
*\.js) node "$file" ;;
|
||
4 years ago
|
*\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;;
|
||
4 years ago
|
*\.nim) nim c -r -d:noColors "$file" ;;
|
||
3 years ago
|
*\.py) python "$file" ;;
|
||
5 years ago
|
*\.go) go run "$file" ;;
|
||
1 year ago
|
*\.lua) lua "$file" ;;
|
||
5 years ago
|
*\.sent) setsid sent "$file" 2>/dev/null & ;;
|
||
1 year ago
|
*\.r|*\.R) Rscript "$file" ;;
|
||
5 years ago
|
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||
|
esac
|