Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (45 sloc) 1.427 kB
# Clean up directory - remove well known tempfiles
emulate -L zsh
setopt HIST_SUBST_PATTERN
local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES
local -a -U FILES
[[ -d "$1" ]] && { TRAPEXIT() { popd -q } && pushd -q "$1" }
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)(.N)'/))
GHCTEMPFILES=(*.(hs|lhs)(N-.:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(.N)'/))
PYTEMPFILES=(*.py(N-.:s/%py/'(pyc|pyo)(.N)'/))
LONELY_MOOD_FILES=((*.mood)(.NDe:'local -a AF;AF=( ${${REPLY#.}%mood}(mp3|flac|ogg|asf|wmv|aac)(N-.) ); [[ -z "$AF" ]]':))
ZSH_COMPILED=(*.zwc(.NDe:'[[ -f ${REPLY%.zwc} && ${REPLY%.zwc} -nt ${REPLY} ]]':))
FILES=(
*~(.N)
\#*\#(.N)
*.o(.N)
a.out(.N)
(*.|)core(|.<->)(.N)
*.cmo(.N)
*.cmi(.N)
.*.swp(.N)
*.(orig|rej)(.DN)
*.dpkg-(old|dist|new)(DN)
._(cfg|mrg)[0-9][0-9][0-9][0-9]_*(N)
${~TEXTEMPFILES}
${~GHCTEMPFILES}
${~PYTEMPFILES}
${LONELY_MOOD_FILES}
${ZSH_COMPILED}
)
local NBFILES=${#FILES}
local CURDIRSUDO=""
[[ ! -w ./ ]] && CURDIRSUDO=$SUDO
if [[ $NBFILES > 0 ]] ; then
print "in $PWD:"
print -f " %s\n" $FILES
local ans
echo -n "Remove these files? [y/N] "
read -q ans; echo
if [[ $ans == [yY] ]] ; then
$CURDIRSUDO rm ${FILES}
echo ">> $PWD purged, $NBFILES files removed"
else
echo "Ok. .. then not.."
fi
fi
Jump to Line
Something went wrong with that request. Please try again.