git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-grep: add --color to highlight matches

From
Jakub Narebski <jnareb@gmail.com>
Date
May 24, 2008, 10:59 UTC
Message-ID
<200805241259.13132.jnareb@gmail.com>
In-Reply-To
<fcaeb9bf0805240220x78943f8ap67344a508531faa0@mail.gmail.com>
On Sat, 24 May 2008, Nguyen Thai Ngoc Duy wrote:
Show 15 quoted lines
> On Sat, May 24, 2008 at 3:28 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>>
>>> +--color::
>>> +     Show colored matches.
>>> +
>>
>> Why not borrow from GNU grep manpage?
>>
>>   --colour[=WHEN], --color[=WHEN]
>>      Surround  the  matching  string  with  the marker find in GREP_COLOR
>>      environment variable. WHEN may be 'never', 'always', or 'auto'
>>
>> We probably would also want it configurable (via config variables),
>> as `color.grep' I guess.
And color.grep.<slot>, where slot can be 'match', and probably later also
'context' (I don't remember if git-grep implements -C<num> option...).
 
> Yes. But this patch was really to scratch my itch and I felt good
> after having it colorized so did not bother with configuration system.
> I will probably make it a config var when I get tired of typing
> --color too often ;)

Thanks for sharing, although I guess Junio would prefer more complete patch...

>> I think compatibility with grep (using GREP_COLOR) would be good idea,
>> and easily implemented.
> 
> I had no idea that variable existed.

Well, I have though that git always use external grep, so this would be for free. After reading the patch more carefully it seems like it isn't so.

Still, perhaps that would be a good idea, but I guess for later patch.
-- 
Jakub Narebski
Poland
Previous: Nguyen Thai Ngoc DuyNext: Andreas Ericsson
Message 4 of 10 in “git-grep: add --color to highlight matches”
  1. git-grep: add --color to highlight matchesNguyễn Thái Ngọc Duy, May 24, 2008
  2. Jakub NarebskiMay 24, 2008
  3. Nguyen Thai Ngoc DuyMay 24, 2008
  4. Jakub NarebskiMay 24, 2008
  5. Andreas EricssonMay 26, 2008
  6. Johannes SchindelinMay 26, 2008
  7. Nguyen Thai Ngoc DuyMay 26, 2008
  8. Johannes SchindelinMay 26, 2008
  9. Nguyen Thai Ngoc DuyMay 26, 2008
  10. Johannes SchindelinMay 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.