1 # Clean up directory - remove well known tempfiles
4 setopt HIST_SUBST_PATTERN
5 local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES
8 [[ -d "$1" ]] && { TRAPEXIT() { popd -q } && pushd -q "$1" }
10 TEXTEMPFILES=(*.tex(N-.:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx|fdb_latexmk|fls|glo|ilg|ind|synctex.gz)(.N)'/))
12 GHCTEMPFILES=(*.(hs|lhs)(N-.:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(.N)'/))
14 PYTEMPFILES=(*.py(N-.:s/%py/'(pyc|pyo)(.N)'/))
16 LONELY_MOOD_FILES=((*.mood)(.NDe:'local -a AF;AF=( ${${REPLY#.}%mood}(mp3|flac|ogg|asf|wmv|aac)(N-.) ); [[ -z "$AF" ]]':))
18 ZSH_COMPILED=(*.zwc(.NDe:'[[ -f ${REPLY%.zwc} && ${REPLY%.zwc} -nt ${REPLY} ]]':))
32 *.dpkg-(old|dist|new)(DN)
33 ._(cfg|mrg)[0-9][0-9][0-9][0-9]_*(N)
41 local NBFILES=${#FILES}
44 [[ ! -w ./ ]] && CURDIRSUDO=$SUDO
46 if [[ $NBFILES > 0 ]] ; then
48 print -f " %s\n" $FILES
50 echo -n "Remove these files? [y/N] "
52 if [[ $ans == [yY] ]] ; then
53 $CURDIRSUDO rm ${FILES}
54 echo ">> $PWD purged, $NBFILES files removed"
56 echo "Ok. .. then not.."