code_junkie

Color regex matches - without dropping misses

Nov 11th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. list_stuff | color_grep "make_this_stand_out_but_dont_hide_the_rest"
  2.  
  3. function sedgrep ()
  4. {
  5. C_PATT=`echo -e '33[33;01m'`
  6. C_NORM=`echo -e '33[m'`
  7.  
  8. sed -s "s/$1/${C_PATT}&${C_NORM}/gi"
  9. }
  10.  
  11. function color_grep {
  12. sed s/$1/$fg[yellow]$1$terminfo[sgr0]/g
  13. }
  14.  
  15. autoload colors zsh/terminfo
  16.  
  17. function colormatch ()
  18. {
  19. tee - | grep --color=always $1 | sort | uniq
  20. }
  21.  
  22. #!/bin/sh
  23. while read line
  24. do
  25. if test `expr "$line" : "==>.*"` -eq 0 ;
  26. then
  27. printf '33[0m%sn' "$line"
  28. else
  29. printf '33[0;31m%sn' "$line"
  30. fi
  31. done
  32.  
  33. regexp=.*red
  34. colours="33[38;5;160m"
  35. count=once
Add Comment
Please, Sign In to add comment