|
|
@ -4,20 +4,22 @@ |
|
|
|
# remove from there. |
|
|
|
|
|
|
|
ext_list="/home/kevin/linux-config/txt/tex-build-files.txt" |
|
|
|
raw_exts="$(tr '\n' '|' < $ext_list)" |
|
|
|
exts="(${raw_exts::-1})" |
|
|
|
# echo "$exts" |
|
|
|
raw_build_exts="$(tr '\n' '|' < $ext_list)" |
|
|
|
build_exts="(${raw_build_exts::-1})" |
|
|
|
# echo "$build_exts" |
|
|
|
find_flags=(-maxdepth 1 -type f -regextype gnu-awk -regex) |
|
|
|
# match all files with build extensions |
|
|
|
regex=(\"^.*\\."$build_exts"$\") |
|
|
|
|
|
|
|
remove_build_files () { |
|
|
|
regex=$2 |
|
|
|
# echo find "$1" "${find_flags[@]}" "$regex" -delete -print |
|
|
|
eval find "$1" "${find_flags[@]}" "$regex" -delete -print |
|
|
|
regex=("$2") |
|
|
|
# eval find "$1" "${find_flags[@]}" "${regex[0]}" -delete -print |
|
|
|
eval find "$1" "${find_flags[@]}" "${regex[0]}" -delete |
|
|
|
} |
|
|
|
|
|
|
|
# when less than one argument, remove build files in current dir |
|
|
|
if [[ "$#" -lt 1 ]]; then |
|
|
|
regex=(\"^.*\\."$exts"$\") |
|
|
|
regex=(\"^.*\\."$build_exts"$\") |
|
|
|
remove_build_files . "${regex[0]}" |
|
|
|
else |
|
|
|
case "$1" in |
|
|
@ -26,12 +28,12 @@ else |
|
|
|
file=$(readlink -f "$1") |
|
|
|
dir=$(dirname "$file") |
|
|
|
base="${file%.*}" |
|
|
|
regex=(\"^"$base"\\."$exts"$\") |
|
|
|
# remove build files matching file name |
|
|
|
regex=(\"^"$base"\\."$build_exts"$\") |
|
|
|
remove_build_files "$dir" "${regex[0]}" ;; |
|
|
|
# remove all build files in directory if given valid one |
|
|
|
*) |
|
|
|
if [[ -d "$1" ]]; then |
|
|
|
regex=(\"^.*\\."$exts"$\") |
|
|
|
remove_build_files "$1" "${regex[0]}" |
|
|
|
else |
|
|
|
printf "Give .tex file or directory as argument.\\n" |
|
|
|