ohmyzsh/lib/grep.zsh

25 lines
588 B
Bash
Raw Normal View History

2014-12-13 11:36:57 -07:00
# is x grep argument available?
grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1
}
2012-06-13 22:06:36 -07:00
2014-12-13 11:36:57 -07:00
# color grep results
GREP_OPTIONS="--color=auto"
2014-12-13 11:36:57 -07:00
# ignore VCS folders (if the necessary grep flags are available)
2014-12-13 11:14:23 -07:00
VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
if grep-flag-available --exclude-dir=.cvs; then
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
elif grep-flag-available --exclude=.cvs; then
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
fi
2014-12-13 11:36:57 -07:00
# export grep settings
export GREP_OPTIONS="$GREP_OPTIONS"
export GREP_COLOR='1;32'
2014-12-13 11:36:57 -07:00
# clean up
unset VCS_FOLDERS
unfunction grep-flag-available