Skip to content

Instantly share code, notes, and snippets.

@orbekk
Created October 13, 2011 12:35
Show Gist options
  • Save orbekk/1284130 to your computer and use it in GitHub Desktop.
Save orbekk/1284130 to your computer and use it in GitHub Desktop.
Simple continous build script for XeLaTeX document
#!/bin/bash
declare -r MAIN=main
declare -r SOURCES=main.tex
declare -r OUTPUT_DIR=build
# Options
declare CONTINUOUS
function launch() {
declare -r COMMAND="${@}"
if [[ -n "${CONTINUOUS}" ]]; then
echo "Building continously..."
declare ITERATION=1
${COMMAND}
while inotifywait ${SOURCES}; do
echo -e "${ITERATION}\t Building..."
${COMMAND}
ITERATION="$((${ITERATION} + 1))"
done
else
${COMMAND}
fi
}
function usage() {
echo "$0 [OPTIONS...]"
echo ""
echo " OPTIONS:"
echo " -c: Enable continuous build (build on file change)"
}
while getopts "ch" OPTION; do
case $OPTION in
c)
CONTINUOUS="true"
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
mkdir -p "${OUTPUT_DIR}"
launch xelatex -halt-on-error -output-directory="${OUTPUT_DIR}" "${MAIN}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment