Created
May 28, 2018 04:03
-
-
Save keeferrourke/e740d420e55bc02ed48a5d80b4812de8 to your computer and use it in GitHub Desktop.
Simple bash script to compile a LaTeX document with pdflatex, and clean up auxillary output files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# latexcompile | |
# Keefer Rourke <[email protected]> | |
# | |
# To the extent possible under law, the person who associated CC0 with | |
# latexcompile has waived all copyright and related or neighboring rights | |
# to latexcompile. | |
# | |
# See <http://creativecommons.org/publicdomain/zero/1.0/> for a copy of | |
# the CC0 legalcode. | |
if [ $# -eq 0 ]; then | |
echo "usage: latexcompile FILE.tex [--open]" | |
echo "cleanly compile LaTeX documents to PDF without cluttering the" \ | |
working directory." | |
exit 2 | |
fi | |
BASE="${1%.*}" | |
pdflatex $1 2>/dev/null 1>&2 | |
if [ $? -ne 0 ]; then | |
echo "Compilation error. Check log." | |
exit 1 | |
fi | |
rm "$BASE.log" "$BASE.aux" "$BASE.out" | |
if [ $2 == "--open" ] || [ $2 == "-o" ]; then | |
xdg-open "$BASE.pdf" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick dirty script to keep me sane while working on LaTeX documents.