Builds XeLaTeX files using a five-step process, with Biber/BibLaTeX.
sh build.sh <latex file>
#!/bin/sh | |
# latexxer main file | |
# | |
# This code is licensed under the GNU General Public License, version 3 or | |
# higher. See <https://gnu.org/licenses/gpl-3.0.txt>. | |
FLAG1=$1 | |
[ $# -gt 0 ] && shift | |
abort() { | |
echo "Abort." >&2 | |
exit 1 | |
} | |
error() { | |
echo "error" | |
abort | |
} | |
echo "$0 by thatlittlegit. (c) 2018, under GNU GPL 3+" | |
echo -n "Checking for filename..." | |
if [ "$FLAG1" != "--tmp" ] && ! [ -z "$FLAG1" ] | |
then | |
FILE=$FLAG1 | |
elif [ "$FLAG2" != "--tmp" ] && ! [ -z "$FLAG2" ] | |
then | |
FILE=$FLAG2 | |
elif [ -f .buildrc ] | |
then | |
FILE=`sed '1q' <.buildrc | tr -d '\n'` | |
else | |
echo "error (no build file found)" | |
abort | |
fi | |
echo "ok [$FILE]" | |
echo -n "Removing extension from '$FILE'..." | |
FILE_NX=`echo $FILE | sed 's/\..*//g'` | |
echo "ok [$FILE_NX]" | |
echo -n "Running XeLaTeX [1]..." | |
yes X | xelatex $* $FILE 2>/tmp/buildsh.x1 >/tmp/buildsh.x1 || error && echo "ok" | |
echo -n "Running Biber [2]..." | |
biber $FILE_NX 2>/tmp/buildsh.bt >/tmp/buildsh.bt || error && echo "ok" | |
echo -n "Running XeLaTeX [3]..." | |
yes X | xelatex $* $FILE 2>/tmp/buildsh.x3 >/tmp/buildsh.x3 || error && echo "ok" | |
echo -n "Running XeLaTeX [4]..." | |
yes X | xelatex $* $FILE 2>/tmp/buildsh.x4 >/tmp/buildsh.x4 || error && echo "ok" | |
echo -n "Cleaning up..." | |
latexmk -c $FILE 2>/dev/null >/dev/null || error | |
rm /tmp/buildsh.?? || error | |
echo "ok" | |
if [ "$FLAG1" = "--tmp" ] || [ "$FLAG2" = "--tmp" ] || [ "$FLAG3" = "--tmp" ] | |
then | |
echo "Copying *.pdf to /tmp..." | |
cp -v *.pdf /tmp | awk 'BEGIN {i=1} {print "\t"i". "$0; i=i+1}' | |
fi | |
echo "$0 finished" |