grep.zsh 559 Bytes
Newer Older
1
2
3
4
#
# Color grep results
# Examples: http://rubyurl.com/ZXv
#
nXqd's avatar
nXqd committed
5

6
7
8
GREP_OPTIONS="--color=auto"

# avoid VCS folders (if the necessary grep flags are available)
9
VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
10

11
12
13
14
grep-flag-available() {
    echo | grep $1 "" >/dev/null 2>&1
}
if grep-flag-available --exclude-dir=.cvs; then
15
    GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
16
elif grep-flag-available --exclude=.cvs; then
17
    GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
18
fi
19
unset VCS_FOLDERS
20
21
unfunction grep-flag-available

22
23
export GREP_OPTIONS="$GREP_OPTIONS"
export GREP_COLOR='1;32'