3 ms·
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=( "$@" ) f
by CGamesPlay 14y ago
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?
- super_mario 14y agoYes, ack --passthu does what you want. I have highlighting turned no in my .profile (export ACK_COLOR_MATCH="bold red").