311f3630d4752139524941298371f9623d493b31
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #3403 from mcornella/fix-grep-library
Fix grep.zsh library
Diff
1diff --git a/lib/grep.zsh b/lib/grep.zsh
2index 276fec382ffbb056fc4f77ef01c0f0a94f22ef94..348ebe62316d8e3865949dcf01fd8906bd6c467b 100644
3--- a/lib/grep.zsh
4+++ b/lib/grep.zsh
5@@ -1,24 +1,24 @@
6-#
7-# Color grep results
8-# Examples: http://rubyurl.com/ZXv
9-#
10-
11-GREP_OPTIONS="--color=auto"
12-
13-# avoid VCS folders (if the necessary grep flags are available)
14+# is x grep argument available?
15 grep-flag-available() {
16 echo | grep $1 "" >/dev/null 2>&1
17 }
18+
19+# color grep results
20+GREP_OPTIONS="--color=auto"
21+
22+# ignore VCS folders (if the necessary grep flags are available)
23+VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
24+
25 if grep-flag-available --exclude-dir=.cvs; then
26- for PATTERN in .cvs .git .hg .svn; do
27- GREP_OPTIONS+=" --exclude-dir=$PATTERN"
28- done
29+ GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
30 elif grep-flag-available --exclude=.cvs; then
31- for PATTERN in .cvs .git .hg .svn; do
32- GREP_OPTIONS+=" --exclude=$PATTERN"
33- done
34+ GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
35 fi
36-unfunction grep-flag-available
37
38-export GREP_OPTIONS="$GREP_OPTIONS"
39-export GREP_COLOR='1;32'
40+# export grep settings
41+alias grep="grep $GREP_OPTIONS"
42+
43+# clean up
44+unset GREP_OPTIONS
45+unset VCS_FOLDERS
46+unfunction grep-flag-available