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

Re: [PATCH v4] help: colorize man pages

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 21, 2021, 21:40 UTC
Message-ID
<60a828cebd2f1_77e4f208b2@natae.notmuch>
In-Reply-To
<YKgXXCvWYI9rjKJT@coredump.intra.peff.net>
Jeff King wrote:
Show 7 quoted lines
> On Fri, May 21, 2021 at 01:01:35PM -0500, Felipe Contreras wrote:
> 
> > > I still don't understand what we gain by making this a Git feature,
> > 
> > What do we gain by making `git diff` output color?
> 
> Huh? Git is outputting the diff. Who else would output the color?

Do you think our users know or care which binary has the final connection to the tty?

Many probably think git is sending the output to `diff --color -u`, and it doesn't matter at all.

Show 7 quoted lines
> > > Why would we do that versus saying: if you want to change the colors in
> > > the tool that Git calls, then configure the tool?
> > 
> > Once again... How?
> 
> By exporting the environment variables that ask it to do so, just like
> you showed already?

Exporting MANPAGER is not enough. That would only work on systems that have SGR disabled.

The user would have to in addition export GROFF_NO_SGR=1, but that would disble groff color for everything, which may not be what the user wants.

There is no MANGROFFNOSGR.
Show 15 quoted lines
> > > If you like to see colors in manpages, why not configure "man" (either
> > > by setting these environment variables all the time, or by triggering
> > > them in MANPAGER)?
> > 
> > Let me try that...
> > 
> >   MANPAGER="less -Dd+r -Du+b -Ds+m" git help git
> > 
> > It doesn't work.
> 
>   ESC=$(printf '\33')
>   export MANCOLORS="LESS_TERMCAP_md=$ESC[31m LESS_TERMCAP_me=$ESC[0m"
>   export MANPAGER='sh -c "eval $MANCOLORS less"'
>   man ls
>   git help git
That still doesn't work here.
https://snipboard.io/GmhRtU.jpg

I see the default docbook colos generated by groff, but not the ones you specified (both on `man` and `git help`).

I need to do this as well:
  export GROFF_NO_SGR=1
Your system probably has groff's SGR disabled in /usr/share/groff/site-tmac/man.local
It's not that simple.

There is in fact a way to configure man to do what we want here but if *nobody* knows what that way is, then does it really matter?

Cheers.
-- 
Felipe Contreras
Previous: Jeff KingNext: Jeff King
Message 12 of 18 in “help: colorize man pages”
  1. help: colorize man pagesFelipe Contreras, May 20, 2021
  2. Phillip WoodMay 20, 2021
  3. Felipe ContrerasMay 20, 2021
  4. Phillip WoodMay 20, 2021
  5. Felipe ContrerasMay 20, 2021
  6. Phillip WoodMay 20, 2021
  7. Felipe ContrerasMay 21, 2021
  8. Junio C HamanoMay 21, 2021
  9. Jeff KingMay 21, 2021
  10. Felipe ContrerasMay 21, 2021
  11. Jeff KingMay 21, 2021
  12. Felipe ContrerasMay 21, 2021
  13. Jeff KingMay 22, 2021
  14. Philip OakleyMay 22, 2021
  15. Felipe ContrerasMay 22, 2021
  16. Felipe ContrerasMay 22, 2021
  17. Felipe ContrerasMay 21, 2021
  18. Leah NeukirchenMay 20, 2021

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.