Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I use the "grep with color for lines plus the empty string" so frequently that I have a function for it:

  function highlight() {
    local args=( "$@" )
    for (( i=0; i<${#args[@]}; i++ )); do
      if [ "${args[$i]:0:1}" != "-" ]; then
        args[$i]="(${args[$i]})|$"
        break
      fi
    done
    grep --color -E "${args[@]}"
  }
This is only to be used as a filter, since it mangles filenames.

I'm curious, does ack support a highlight-only mode?



Yes, ack --passthu does what you want. I have highlighting turned no in my .profile (export ACK_COLOR_MATCH="bold red").




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: