Permalink
Browse files

zsh: purge: make purge take an optional dir argument so it can be use…

…d e.g. with zargs --max-args 1 -- **/ -- purge
  • Loading branch information...
1 parent 2ebcbd6 commit a4cd061ce9e2659aaad733e5a601574233c112d7 Bernhard Tittelbach committed Apr 13, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 usr_share_grml/zsh/functions/purge
View
5 usr_share_grml/zsh/functions/purge
@@ -4,6 +4,8 @@ emulate -L zsh
setopt HIST_SUBST_PATTERN
local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES 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)(N)'/))
GHCTEMPFILES=(*.(hs|lhs)(N:r:s/%/'.(hi|hc|(p|u|s)_(o|hi))(N)'/))
@@ -39,7 +41,8 @@ local CURDIRSUDO=""
[[ ! -w ./ ]] && CURDIRSUDO=$SUDO
if [[ $NBFILES > 0 ]] ; then
- print -l $FILES
+ print "in $PWD:"
+ print -f " %s\n" $FILES
local ans
echo -n "Remove these files? [y/N] "
read -q ans; echo

0 comments on commit a4cd061

Please sign in to comment.