grep.zsh 602 B

123456789101112131415161718192021222324
  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. grep-flag-available() {
  8. echo | grep $1 "" >/dev/null 2>&1
  9. }
  10. if grep-flag-available --exclude-dir=.cvs; then
  11. for PATTERN in .cvs .git .hg .svn; do
  12. GREP_OPTIONS+=" --exclude-dir=$PATTERN"
  13. done
  14. elif grep-flag-available --exclude=.cvs; then
  15. for PATTERN in .cvs .git .hg .svn; do
  16. GREP_OPTIONS+=" --exclude=$PATTERN"
  17. done
  18. fi
  19. unfunction grep-flag-available
  20. export GREP_OPTIONS="$GREP_OPTIONS"
  21. export GREP_COLOR='1;32'