1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-03-19 02:17:44 +01:00

46 lines
1.6 KiB
Plaintext
Raw Normal View History

2019-10-16 16:25:42 +02:00
#!/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
2020-04-02 00:06:34 +02:00
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
2019-10-16 16:25:42 +02:00
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
basenodir="${1%.*}"
2019-10-16 16:25:42 +02:00
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" &&
makeglossaries "$basenodir" &&
2019-10-16 16:25:42 +02:00
$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 ;;
*\.m) octave -qW "$file" ;;
2019-10-16 16:25:42 +02:00
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
*config.h) sudo make install ;;
*\.tex) textype "$file" ;;
2021-09-17 04:35:24 +02:00
*\.java) java "$file" ;;
2021-06-20 13:44:32 +02:00
*\.js) node "$file" ;;
*\.c) if [ -f Makefile ]; then make run; else cc "$file" -o "$base" && "$base"; fi ;;
*\.nim) nim c -r -d:noColors "$file" ;;
2021-06-20 13:44:32 +02:00
*\.py) python3 "$file" ;;
2019-10-16 16:25:42 +02:00
*\.go) go run "$file" ;;
*\.sent) setsid sent "$file" 2>/dev/null & ;;
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac