My first useful, original script
LaTeX is wonderful, but it clutters up my folders with .aux, .bbl, and other files. So I wrote this script for one-part articles:
#!/bin/bash
# q-tex - takes a .tex file, copies it to a hidden directory, runs
# pdflatex (and later, bibtex), and writes a symlink to the .pdf in
# the original directory.
workdir=".q-tex"
if [ $# -eq 0 ] ; then
echo "Usage: $0 basefilename (no .tex extension)" >&2
exit 1
fi
if [ $(echo $1 | grep '.tex') ] ; then
echo "Usage: 0$ basefilename (OMIT .tex EXTENSION)"
fi
basefilename="$(echo $1 | sed 's/.tex$//g')"
if [ ! -d $workdir ] ; then
echo "q-tex directory does not exist yet; creating it."
mkdir .q-tex
fi
if [ -s ${basefilename}.pdf ] ; then
rm ${basefilename}.pdf ;
elif [ -f ${basefilename}.pdf ] ; then
echo "There is already ${basefilename}.pdf in this directory. Delete or rename it to use $0"
exit 1
fi
cp $1 $workdir/
cd $workdir
pdflatex $basefilename
cd ..
ln -s $workdir/${basefilename}.pdf ${basefilename}.pdf
exit 0
# TODO: use the same basic plan with .bib file: copy it to .q-tex, run
# stuff there, return to original directory. This way, I can have my
# RCS directories in the original directory without screwing things
# up. Where should I keep my .sty files, though? bibq-tex.sh

0 Comments:
Post a Comment
<< Home