Here's a little bash script to compile (pdflatex
, bitex
, 2*pdflatex
,etc.) the most recent .tex
file in your current directory that contains begin{document}
(i.e. the main document):
#!/bin/bash
if [ -z "$LMAKEFILE" ]; then
echo "Error: didn't find LMAKEFILE environment variable"
exit 1
fi
TEX=$( \
grep -Il1dskip "begin{document}" *.tex | \
xargs stat -f "%m %N" | \
sort -r | \
head -n 1 | \
sed -e "s/^[^ ]* //")
BASE="${TEX%.*}"
if [ -z "$TEX" ]; then
echo "Error: Didn't find begin{document} in any .tex files"
exit 1
fi
make -f $LMAKEFILE $BASE && open $BASE.pdf
Simply use it:
texmake