From 7fe112a0b1c972b828c8e4a7cfd61f74ad5c465c Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 20 Jan 2022 16:49:55 -0600 Subject: [PATCH] Added deletion support in latex-cleanup --- latex-cleanup | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/latex-cleanup b/latex-cleanup index 59a53ec..43c9aaf 100644 --- a/latex-cleanup +++ b/latex-cleanup @@ -1,18 +1,26 @@ #!/bin/sh # I use it to clean up latex build files from a directory after I'm done with the project. - +# Just run it inside the directory with the files. # Depends on trash-cli +# Pass "-delete" to delete files instead of trashing. + +if [ "$1" = "-delete" ]; then + echo "Warning: Deleting instead of trashing." + d=1 +else + d=0 +fi for f in *.tex; do if [ -f "$f" ]; then h=$(basename "$f" .tex) - echo "Trashing files accompanying $h.tex..." + echo "Removing files accompanying $h.tex..." for g in "$h".*; do k=$( echo $g | sed 's/^.*\.//') if [ "$k" != "tex" ] && [ "$k" != "pdf" ] && [ "$k" != "bib" ] ; then - echo "Trashing $g..." - trash "$g" + echo "Removing $g..." + [ $d -eq 0 ] && trash "$g" || rm "$g" fi done fi