Blame view

repos/robbyrussell/oh-my-zsh/lib/grep.zsh 645 Bytes
093a6c34b   mj   Squashed 'repos/r...
1
2
3
4
  # is x grep argument available?
  grep-flag-available() {
      echo | grep $1 "" >/dev/null 2>&1
  }
56a5793ce   mj   Squashed 'repos/r...
5
  GREP_OPTIONS=""
093a6c34b   mj   Squashed 'repos/r...
6
  # color grep results
56a5793ce   mj   Squashed 'repos/r...
7
8
9
  if grep-flag-available --color=auto; then
      GREP_OPTIONS+=" --color=auto"
  fi
093a6c34b   mj   Squashed 'repos/r...
10
11
  
  # ignore VCS folders (if the necessary grep flags are available)
ed37aae5b   mj   Squashed 'repos/r...
12
  VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}"
093a6c34b   mj   Squashed 'repos/r...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  
  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