grep.zsh 559 B

1234567891011121314151617181920212223
  1. #
  2. # Color grep results
  3. # Examples: http://rubyurl.com/ZXv
  4. #
  5. GREP_OPTIONS="--color=auto"
  6. # avoid VCS folders (if the necessary grep flags are available)
  7. VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
  8. grep-flag-available() {
  9. echo | grep $1 "" >/dev/null 2>&1
  10. }
  11. if grep-flag-available --exclude-dir=.cvs; then
  12. GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
  13. elif grep-flag-available --exclude=.cvs; then
  14. GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
  15. fi
  16. unset VCS_FOLDERS
  17. unfunction grep-flag-available
  18. export GREP_OPTIONS="$GREP_OPTIONS"
  19. export GREP_COLOR='1;32'