Open jaroslawr opened 4 years ago
Can you specify the desired behavior when -v
is used and matches in the context lines are highlighted? e.g., This is how ripgrep behaves now:
In the second example, bar
is highlighted as a match even though it is in a non-matching context line.
I guess it looks like grep combines them?
Not quite sure how I feel about adding yet another color option though. Although I can see how "graying" out the context could lead to a nice effect.
git grep
also has the feature in question and has more understandable options than GREP_COLORS
, it provides these color settings:
match
matching text (same as setting matchContext and matchSelected)matchSelected
matching text in selected linesmatchContext
matching text in context lines (I guess covers the -v
case you described)selected
non-matching text in selected linescontext
non-matching text in context lines
(per https://git-scm.com/docs/git-config, under "color.grep" section)Taking inspiration from this, I think ripgrep
could allow to set one or both of new options: matchSelected
and matchContext
, which when set would take precedence over the match
option. Analogously it could allow to set lineSelected
and lineContext
, taking precedence over line
when set.
It would be nice to be able to specify different coloring for context lines - lines that do not contain a match but come from application of
-A/-B/-C
options, e.g.rg --color nomatchline:fg:gray,line:fg:white
. This is possible in vanilla grep like this: