1 # Clean up directory - remove well known tempfiles
4 setopt HIST_SUBST_PATTERN
5 local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES FILES
7 [[ -d "$1" ]] && { TRAPEXIT() { popd -q } && pushd -q "$1" }
9 TEXTEMPFILES=(*.tex(N:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(N)'/))
11 GHCTEMPFILES=(*.(hs|lhs)(N:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(N)'/))
13 PYTEMPFILES=(*.py(N:s/%py/'(pyc|pyo)(N)'/))
15 LONELY_MOOD_FILES=((*.mood)(.NDe:'local -a AF;AF=( ${${REPLY#.}%mood}(mp3|flac|ogg|asf|wmv|aac)(N) ); [[ -z "$AF" ]]':))
17 ZSH_COMPILED=(*.zwc(.NDe:'[[ -f ${REPLY%.zwc} && ${REPLY%.zwc} -nt ${REPLY} ]]':))
29 *.dpkg-(old|dist|new)(DN)
30 ._(cfg|mrg)[0-9][0-9][0-9][0-9]_*(N)
38 local NBFILES=${#FILES}
41 [[ ! -w ./ ]] && CURDIRSUDO=$SUDO
43 if [[ $NBFILES > 0 ]] ; then
45 print -f " %s\n" $FILES
47 echo -n "Remove these files? [y/N] "
49 if [[ $ans == [yY] ]] ; then
50 $CURDIRSUDO rm ${FILES}
51 echo ">> $PWD purged, $NBFILES files removed"
53 echo "Ok. .. then not.."