Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ohmybash/oh-my-bash
Browse files Browse the repository at this point in the history
  • Loading branch information
mengruxing committed Dec 27, 2021
2 parents 3a69a16 + 81fc5dd commit 4959dc5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ grep_flag_available() {
echo | grep $1 "" >/dev/null 2>&1
}

GREP_OPTIONS=""
GREP_OPTIONS=()

# color grep results
if grep_flag_available --color=auto; then
GREP_OPTIONS+=( " --color=auto" )
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" )
GREP_OPTIONS+=( "--exclude-dir=$VCS_FOLDERS" )
elif grep_flag_available --exclude=.cvs; then
GREP_OPTIONS+=( " --exclude=$VCS_FOLDERS" )
GREP_OPTIONS+=( "--exclude=$VCS_FOLDERS" )
fi

# export grep settings
alias grep="grep $GREP_OPTIONS"
alias grep="grep ${GREP_OPTIONS[*]}"

# clean up
unset GREP_OPTIONS
Expand Down

0 comments on commit 4959dc5

Please sign in to comment.