# An ugly hack to speed up pdflatex using the minted package
# place this file with the name 'pygmentize' somewhere on your
# path before the 'real' pygmentize, such that this file gets
# executed and can act as a wrapper around the 'real' pygmentize.
# This script computes a hash-value (md5sum) of the input file
# from minted and caches the output of pygmentize.
# The working directory is used to store the cached files (it's an ugly hack...)
# The real pygmentize command, may need customization to work on your system.
# Use 'whereis pygmentize' to found the location on your system.
# find the output file used by minted
for arg in $@
if [ $take_outfile -eq 1 ]
if [ $arg = -o ]
# the last parameter is the input file
# compute the hash value of the input
hash=$( md5sum $infile | cut -d' ' -f1 )
if [ -f "$hash" ]
# we have cached output from pygmentize
cp "$hash" "$outfile"
# call 'real' pygmentize and cache the result
cp "$outfile" "$hash"