2021-12-28 02:54:26 -06:00
|
|
|
#!/bin/sh
|
2021-04-19 13:54:49 -05:00
|
|
|
|
2022-01-02 22:35:07 -06:00
|
|
|
# I use it to clean up latex build files from a directory after I'm done with the project.
|
2022-01-20 16:49:55 -06:00
|
|
|
# Just run it inside the directory with the files.
|
2021-12-31 02:07:19 -06:00
|
|
|
# Depends on trash-cli
|
2022-01-20 16:49:55 -06:00
|
|
|
# Pass "-delete" to delete files instead of trashing.
|
|
|
|
|
2022-01-22 18:38:30 -06:00
|
|
|
if [ "$1" = "--delete" ]; then
|
2022-07-29 22:41:54 -05:00
|
|
|
read -p "Warning: Deleting instead of trashing. Continue? [y/N]: " resp
|
|
|
|
if [ $resp != "y" ] && [ $resp != "Y" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
2022-01-20 16:49:55 -06:00
|
|
|
d=1
|
|
|
|
else
|
2022-01-22 18:38:30 -06:00
|
|
|
echo "Trashing files by default, pass --delete to delete instead."
|
2022-01-20 16:49:55 -06:00
|
|
|
d=0
|
|
|
|
fi
|
2021-12-31 02:07:19 -06:00
|
|
|
|
2021-06-29 12:20:52 -05:00
|
|
|
for f in *.tex; do
|
2021-12-28 23:59:05 -06:00
|
|
|
if [ -f "$f" ]; then
|
|
|
|
h=$(basename "$f" .tex)
|
2022-01-20 16:49:55 -06:00
|
|
|
echo "Removing files accompanying $h.tex..."
|
2021-12-28 23:59:05 -06:00
|
|
|
for g in "$h".*; do
|
|
|
|
k=$( echo $g | sed 's/^.*\.//')
|
|
|
|
if [ "$k" != "tex" ] && [ "$k" != "pdf" ] && [ "$k" != "bib" ] ; then
|
2022-01-20 16:49:55 -06:00
|
|
|
echo "Removing $g..."
|
|
|
|
[ $d -eq 0 ] && trash "$g" || rm "$g"
|
2021-12-28 23:59:05 -06:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2021-06-29 12:20:52 -05:00
|
|
|
done
|
2022-01-22 18:38:30 -06:00
|
|
|
|
2021-04-19 13:54:49 -05:00
|
|
|
echo "Done!"
|