Advertisement
Guest User

buildPDF

a guest
Jan 6th, 2015
351
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None
  1. #!/bin/bash
  2. # A script for automatically creating PDf files from a latex document
  3. # You can set the number of builds
  4. # Usage: ./buildpdf.sh filename [build amount] PDFLATEX_ARGS
  5. # Marcel Michael Kapfer, Elias Toivanen
  6. # 6th January 2015
  7. # GNU GPL v3.0 -> Feel free to re-distribute it or fork it
  8. if [[ -z "$1" ]]; then
  9.     echo "Usage: $(basename $0) filename [-n build amount (Default: 1)] [PDFLATEX_ARGS]"
  10.     exit 1
  11. fi
  12.  
  13. if ! which inotifywait > /dev/null; then
  14.     echo "ERROR: inotifywait not found in path. Is inotify-tools installed?" >&2
  15.     exit 1
  16. fi
  17.  
  18. filename=$1
  19. if [[ ! -r "$filename" ]]; then
  20.     echo "ERROR: The input file \`$filename' name is not readable.">&2
  21.     exit 1
  22. fi
  23.  
  24. shift
  25.  
  26. builds=1
  27. if [[ "$1" == "-n" ]]; then
  28.     shift
  29.     builds=$1
  30.     shift
  31. fi
  32.  
  33. args=""
  34. if (( $# )); then
  35.     args="$@"
  36. fi
  37.  
  38. while inotifywait --event modify $filename; do
  39.     for ((i=1 ; i<=$builds ; ++i)); do
  40.         pdflatex "$args" "$filename"
  41.         echo "Build $i ready"
  42.     done
  43. done
Advertisement
RAW Paste Data Copied
Advertisement