git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Colorize matches for git log --grep=pattern?
@ 2017-11-01 10:57 Sebastian Schuberth
  2017-11-01 18:50 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Schuberth @ 2017-11-01 10:57 UTC (permalink / raw)
  To: git

Hi,

is there a way to colorize / highlight the pattern matched by

     git log -E -i --grep=pattern

in the console output?

Regards,
Sebastian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Colorize matches for git log --grep=pattern?
  2017-11-01 10:57 Colorize matches for git log --grep=pattern? Sebastian Schuberth
@ 2017-11-01 18:50 ` Jeff King
  2017-11-01 19:54   ` Sebastian Schuberth
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2017-11-01 18:50 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: git

On Wed, Nov 01, 2017 at 11:57:14AM +0100, Sebastian Schuberth wrote:

> is there a way to colorize / highlight the pattern matched by
> 
>     git log -E -i --grep=pattern
> 
> in the console output?

I don't think so. The grep code _does_ know about colorizing matches
(which is why "git grep --color" works), but for the output code path
for commit messages doesn't use grep at all (it couldn't, because we're
not just showing the relevant lines but selecting the whole commit).

So I think it would have to be reimplemented separately.

The best workaround I could come up with is passing the output through a
highlighting script:

  git log --grep=foo --color |
  perl -pe 's/foo/\x1b[1;31m$&\x1b[m/' |
  less

Pretty hacky.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Colorize matches for git log --grep=pattern?
  2017-11-01 18:50 ` Jeff King
@ 2017-11-01 19:54   ` Sebastian Schuberth
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Schuberth @ 2017-11-01 19:54 UTC (permalink / raw)
  To: Jeff King; +Cc: Git Mailing List

On Wed, Nov 1, 2017 at 7:50 PM, Jeff King <peff@peff.net> wrote:

> The best workaround I could come up with is passing the output through a
> highlighting script:
>
>   git log --grep=foo --color |
>   perl -pe 's/foo/\x1b[1;31m$&\x1b[m/' |
>   less
>
> Pretty hacky.

Thanks anyway. I was also considering something like this, but
likewise found it to be too hacky.

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-01 19:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 10:57 Colorize matches for git log --grep=pattern? Sebastian Schuberth
2017-11-01 18:50 ` Jeff King
2017-11-01 19:54   ` Sebastian Schuberth

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).