I do have the following find-file
script:
find . -type f -iname "*$1*" -printf '%P\n' \
| GREP_COLORS="sl=0;33;49:ms=1;34;49" grep --color=always '^\|[^/]*$' \
| grep -i --color=auto "$1"
which does:
- colorize the path part
- colorize the pattern in the base name part
Problem: after the pattern, the colour is reset
For the base name part, it could be entirely white, that'd solve the problem (though I did not find the way to change this).
For the path part, it'd stay a problem, as you can see in the above screenshot: the colour is reset, hence we don't see anymore where the file path really ends!
Is there a solution to this?
EDIT -- There were 3 solutions to this!! All below proposals do work, they have light differences, but they do answer the question. I choose the one which highlights all occurrences of the pattern, and is almost a one-line, but honestly choosing was tough, as they're quite equivalent…
EDIT -- One wished improvement to this: that the find results don't get blocked until analysis, that is that the output gets flushed and processed line per line. Is this possible?
ne
ofGREP_COLORS
(seeman grep
). Tried it, but addingGREP_COLORS="ne=1"
before the last grep does not solve the problem. It even uses theGREP_COLOR
instead!?