Skip to content

Instantly share code, notes, and snippets.

@dhondta
Forked from djsutherland/latex-clean.sh
Created April 15, 2022 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhondta/e398351bdf4b02aa4bb8f0d7eb8d9637 to your computer and use it in GitHub Desktop.
Save dhondta/e398351bdf4b02aa4bb8f0d7eb8d9637 to your computer and use it in GitHub Desktop.
A bash script to clean latex temp files
#!/bin/bash
# Note: you might prefer latexmk -c since latexmk is great. It doesn't clean all of these, but see
# https://tex.stackexchange.com/questions/83341/clean-bbl-files-with-latexmk-c/83386#83386
exts="-blx.aux -blx.bib -blx.bib .acn .acr .alg .algorithms .aux .bbl .bcf .blg .brf .dvi .fdb_latexmk .fls .glg"\
" .glo .gls .glsdefs .idx .ilg .ind .ist .keys .listing .loa .lof .log .lol .lot .maf .mtc .mtc0 .mw .nav .nlo"\
" .out .pdfsync .ptc .pyg .run.xml .snm .synctex.gz .syntex.gz(busy) .tdo .thm .toc .vrb .xdy"
for x in "${@:-.}"; do
arg=$(echo ${x:-.} | perl -pe 's/\.(tex|pdf)$//')
if [[ -d "$arg" ]]; then
for ext in $exts; do
rm -f "$arg"/*$ext
done
else
for ext in $exts; do
rm -f "$arg"$ext
done
fi
done
# rm -rf $(biber --cache) # gross biber bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment