Dotfiles for different machines on different branches.
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.

40 lines
1.5 KiB

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