Created
October 13, 2011 12:35
-
-
Save orbekk/1284130 to your computer and use it in GitHub Desktop.
Simple continous build script for XeLaTeX document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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