dotfiles/zsh/libs/grep.zsh
2019-12-12 16:29:20 +01:00

23 lines
493 B
Bash

grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1
}
GREP_OPTIONS=""
if grep-flag-available --color=auto; then
GREP_OPTIONS+=" --color=auto"
fi
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
alias grep="grep $GREP_OPTIONS"
unset GREP_OPTIONS
unset VCS_FOLDERS
unfunction grep-flag-available