711843153d6e53a89d37931217f59c4f6a3a35db

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Tidy up the grep.zsh library

Diff

 1diff --git a/lib/grep.zsh b/lib/grep.zsh
 2index 06751db1a6c32c11c112ec6e8c13cfb54ae6e87a..4e55464c5b4ddf83b8ced482a55c1eb02348f88d 100644
 3--- a/lib/grep.zsh
 4+++ b/lib/grep.zsh
 5@@ -1,23 +1,24 @@
 6-#
 7-# Color grep results
 8-# Examples: http://rubyurl.com/ZXv
 9-#
10+# is x grep argument available?
11+grep-flag-available() {
12+    echo | grep $1 "" >/dev/null 2>&1
13+}
14 
15+# color grep results
16 GREP_OPTIONS="--color=auto"
17 
18-# avoid VCS folders (if the necessary grep flags are available)
19+# ignore VCS folders (if the necessary grep flags are available)
20 VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
21 
22-grep-flag-available() {
23-    echo | command grep $1 "" >/dev/null 2>&1
24-}
25 if grep-flag-available --exclude-dir=.cvs; then
26     GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
27 elif grep-flag-available --exclude=.cvs; then
28     GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
29 fi
30-unset VCS_FOLDERS
31-unfunction grep-flag-available
32 
33+# export grep settings
34 export GREP_OPTIONS="$GREP_OPTIONS"
35 export GREP_COLOR='1;32'
36+
37+# clean up
38+unset VCS_FOLDERS
39+unfunction grep-flag-available