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.
65 lines
2.3 KiB
65 lines
2.3 KiB
6 years ago
|
#!/bin/sh
|
||
|
|
||
|
# This script will compile or run another finishing operation on a document. I
|
||
|
# have this script run via vim.
|
||
|
#
|
||
|
# tex files: Compiles to pdf, including bibliography if necessary
|
||
|
# md files: Compiles to pdf via pandoc
|
||
|
# rmd files: Compiles via R Markdown
|
||
|
# c files: Compiles via whatever compiler is set to cc. Usually gcc.
|
||
|
# py files: runs via python command
|
||
|
# go files: compiles and runs with "go run"
|
||
|
# config.h files: (For suckless utils) recompiles and installs program.
|
||
|
# all others: run `sent` to show a presentation
|
||
|
|
||
|
file=$(readlink -f "$1")
|
||
|
dir=$(dirname "$file")
|
||
|
base="${file%.*}"
|
||
|
shebang=$(sed -n 1p "$file")
|
||
|
|
||
|
cd "$dir" || exit
|
||
|
|
||
|
textype() { \
|
||
|
command="pdflatex"
|
||
|
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
|
||
6 years ago
|
$command --output-directory="$dir" "$file"
|
||
|
#grep -i addbibresource "$file" >/dev/null &&
|
||
|
#biber --input-directory "$dir" "$base" &&
|
||
|
#$command --output-directory="$dir" "$base" &&
|
||
|
#$command --output-directory="$dir" "$base"
|
||
6 years ago
|
}
|
||
|
|
||
|
mdtype(){ \
|
||
|
command=${2:-"default"}
|
||
|
echo "$command"
|
||
|
case "$command" in
|
||
6 years ago
|
"fplreport") pandoc "$file" --metadata-file="$HOME/.dotfiles/pandoc/defaults.yaml" --template fellowship.latex --pdf-engine=xelatex -o "${base}.pdf" ;;
|
||
|
"letter") pandoc "$file" --metadata-file="$HOME/.dotfiles/pandoc/defaults.yaml" --template template-letter.tex -o "${base}.pdf" ;;
|
||
|
*) pandoc "$file" --metadata-file="$HOME/.dotfiles/pandoc/defaults.yaml" -o "$base".pdf ;;
|
||
6 years ago
|
esac
|
||
|
}
|
||
6 years ago
|
|
||
|
shebangtest() {
|
||
|
case "$shebang" in
|
||
|
\#\!*) "$file" ;;
|
||
|
*) sent "$file" 2>/dev/null & ;;
|
||
|
esac
|
||
|
}
|
||
|
|
||
|
case "$file" in
|
||
|
*\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;;
|
||
|
*\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
|
||
|
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
|
||
|
*\.tex|*\.latex) textype "$file" ;;
|
||
|
#*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
|
||
6 years ago
|
#*\.md) pandoc "$file" -o "$base".pdf ;;
|
||
6 years ago
|
/tmp/neomutt*|*\.md) mdtype "$file" "$2" ;;
|
||
6 years ago
|
*config.h) make && sudo make install ;;
|
||
|
*\.c) cc "$file" -o "$base" && "$base" ;;
|
||
|
*\.py) python "$file" ;;
|
||
6 years ago
|
*\.js) cat "$file" | minify --js > "${base}.min.js" ;;
|
||
6 years ago
|
*\.less) lessc --clean-css --source-map --autoprefix="last 3 versions, ie >= 11" "$file" "${base}.min.css" ;;
|
||
6 years ago
|
#*\.go) go run "$file" ;;
|
||
|
#*) shebangtest ;;
|
||
|
esac
|