zshrc: Move purge to its own file
authorFrank Terbeck <ft@bewatermyfriend.org>
Mon, 28 Nov 2011 21:48:06 +0000 (22:48 +0100)
committerMichael Prokop <mika@grml.org>
Tue, 6 Dec 2011 13:50:45 +0000 (14:50 +0100)
Signed-off-by: Frank Terbeck <ft@bewatermyfriend.org>
etc/zsh/zshrc
usr_share_grml/zsh/functions/purge [new file with mode: 0644]

index 93055d8..96509d4 100644 (file)
@@ -2896,34 +2896,6 @@ lcheck() {
     fi
 }
 
-#f5# Clean up directory - remove well known tempfiles
-purge() {
-    emulate -L zsh
-    setopt HIST_SUBST_PATTERN
-    local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES FILES
-    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)'/))
-    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 -l $FILES
-        local ans
-        echo -n "Remove these files? [y/n] "
-        read -q ans; echo
-        if [[ $ans == "y" ]] ; then
-            $CURDIRSUDO rm ${FILES}
-            echo ">> $PWD purged, $NBFILES files removed"
-        else
-            echo "Ok. .. then not.."
-        fi
-    fi
-}
-
 # Translate DE<=>EN
 # 'translate' looks up fot a word in a file with language-to-language
 # translations (field separator should be " : "). A typical wordlist looks
diff --git a/usr_share_grml/zsh/functions/purge b/usr_share_grml/zsh/functions/purge
new file mode 100644 (file)
index 0000000..aa5066a
--- /dev/null
@@ -0,0 +1,52 @@
+# Clean up directory - remove well known tempfiles
+emulate -L zsh
+
+setopt HIST_SUBST_PATTERN
+local -a TEXTEMPFILES GHCTEMPFILES PYTEMPFILES FILES
+
+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)'/))
+
+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 -l $FILES
+    local ans
+    echo -n "Remove these files? [y/n] "
+    read -q ans; echo
+    if [[ $ans == "y" ]] ; then
+        $CURDIRSUDO rm ${FILES}
+        echo ">> $PWD purged, $NBFILES files removed"
+    else
+        echo "Ok. .. then not.."
+    fi
+fi