Changes

Jump to navigation Jump to search
1,481 bytes added ,  11:03, 20 September 2017
new
While ConTeXt (i.e. mtxrun) already automates a lot, in bigger projects I find it tedious to call context with all its options all the time. One might use [https://www.gnu.org/software/make/ make] or [https://github.com/cereda/arara arara], but I mostly use shell scripts (on OSX and Linux). Here are some useful snippets:

<pre>
#!/bin/bash

OS=`uname`
if [ "$TEXROOT" == "" ]; then
# setup ConTeXt’s path; I used different locations on OSX and Linux
# You might also check on the hostname or if the path exists
if [ "$OS" == "Linux" ]; then
source /var/opt/context/tex/setuptex /var/opt/context/tex
elif [ "$OS" == "Darwin" ]; then
source ~/Library/texmf/tex/setuptex ~/Library/texmf/tex
fi
fi

# ulimit was 256 on older OSX versions, that's too low for bigger books
if [ `ulimit` != "unlimited" ]; then
ulimit -S -n 2048
fi

# I like to have my PDFs versioned at least by date
ISODATE=`date +"%Y-%m-%d"`

PRD=$1
if [ "$1" == "" ]; then
echo Which product?
ls -Alh prd_*.tex
exit 1
fi
RESULT=${PRD}_${ISODATE}

MODE=$2
if [ "$MODE" == "" ]; then
echo Using lowres pictures for preview. Use 'print' parameter for highres mode.
MOD=lowres
else
# print
RESULT=${RESULT}_$MODE
fi

if [ "$OS" == "Darwin" ]; then
OPEN='open -a Preview'
SHARE=~/Box
else
OPEN="qpdfview --quiet"
SHARE=~/Dropbox
fi

context --jit prd_${PRD} --result=_pdf/$RESULT --mode=$MOD
if [ "$?" == "0" ]; then
${OPEN} _pdf/$RESULT.pdf &
cp _pdf/${RESULT}.pdf ${SHARE}/projects/
fi

</pre>

Navigation menu