From 55457187d18221e76bd12f0fb2cfab65c49b92fb Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 5 Mar 2019 01:09:01 +0100 Subject: Initial commit --- .oh-my-zsh/lib/grep.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .oh-my-zsh/lib/grep.zsh (limited to '.oh-my-zsh/lib/grep.zsh') diff --git a/.oh-my-zsh/lib/grep.zsh b/.oh-my-zsh/lib/grep.zsh new file mode 100644 index 0000000..abc1650 --- /dev/null +++ b/.oh-my-zsh/lib/grep.zsh @@ -0,0 +1,28 @@ +# is x grep argument available? +grep-flag-available() { + echo | grep $1 "" >/dev/null 2>&1 +} + +GREP_OPTIONS="" + +# color grep results +if grep-flag-available --color=auto; then + GREP_OPTIONS+=" --color=auto" +fi + +# ignore VCS folders (if the necessary grep flags are available) +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 + +# export grep settings +alias grep="grep $GREP_OPTIONS" + +# clean up +unset GREP_OPTIONS +unset VCS_FOLDERS +unfunction grep-flag-available -- cgit v1.2.3