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

Re: [PATCH] help: colorize man pages

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 19, 2021, 11:45 UTC
Message-ID
<60a4fa4dc7701_86a820896@natae.notmuch>
In-Reply-To
<YKTkIgdJgBomzieH@coredump.intra.peff.net>
Jeff King wrote:
Show 30 quoted lines
> On Wed, May 19, 2021 at 11:26:12AM +0200, Ævar Arnfjörð Bjarmason wrote:
> 
> > > There's a big difference between Git coloring a Git UI, like a diff, and
> > > Git coloring a separate program that already has sensible, standard
> > > defaults.  A user who has not configured any color settings would
> > > probably not want Git to render manual pages one way, cargo to render
> > > manual pages a second way, and still other programs to render manual
> > > pages in other, incompatible ways.  We need to consider not only the
> > > impact that our decisions have in a vacuum, but what results similar
> > > decisions from other projects would produce in the software ecosystem as
> > > a whole.
> > >
> > > Would you consider various projects coloring their respective manual
> > > pages differently to be a desirable state of affairs?
> > 
> > I think it's an important distinction that we're not coloring any manual
> > pages, it's a question of whether we invoke "man" invoked by "git help
> > <whatever>" with the exact same paramaters/options a user would get with
> > "man git-<whatever>".
> > 
> > Right now our documentation seems to suggest that we won't do any such
> > magic, but you can also set man.viewer to e.g. invoke a web browser or
> > something instead of man(1).
> > 
> > I don't think it's confusing in that context if we learn to do some "man
> > with fancy on top" in this mode.
> 
> I agree that we could explain it as "man with fancy on top". But it
> makes me wonder: why is this Git's responsibility to do the fancy at
> all?
It is not.
Just like it is not git's responsibility to display diffs in color.
But it's a nice thing to do.
> I.e., if you want colorized manpages, why don't you configure man to do
> so?
Because this has nothing to do with man.

In the default mode man just takes the output of groff, and passes it to a pager. That's it.

It doesn't know anything of colors. That's between groff and less.
> Sure, it's a bit of a pain to do so since it involves setting a
> bunch of obscure environment variables.
The environment variables are for less, not man.

If you export those variables into your environment, you could potentially mess up the output of some programs when viewed through less.

That's why in my tip I set the variables only for man, inside a man function wrap: man () { FOO=1 command man "$@"; }

> But if that's what you want, wouldn't you want it for all manpages,
> whether you ran "git help log" or "man git-log" or "man ls"?

How? (without messing up the environment for other programs that use a pager)

> This seems like a "man" feature and not a "git" feature.

man does not care. It can do many things, dumping data onto a pager is just one of them.

Where does LESS_TERMCAP_* affect `man -Hchromium git`? For more read man man.
> And arguably some of it is really a "less" feature
It's *all* a less feature.
> (it is trying to set "standout" mode for its prompt, so configuring
> "so" and "se" termcap entries is just reinterpreting that. If you
> like, wouldn't you want it on for all "less" invocations?).
I don't.

Rendering things correctly on a terminal is tricky enough as it is, I would like to hedge such kinds of changes inside a controlled environment.

Which is exactly what my patch does.
-- 
Felipe Contreras
Previous: Jeff KingNext: Felipe Contreras
Message 24 of 33 in “help: colorize man pages”
  1. help: colorize man pagesFelipe Contreras, May 18, 2021
  2. brian m. carlsonMay 18, 2021
  3. Felipe ContrerasMay 18, 2021
  4. brian m. carlsonMay 18, 2021
  5. Junio C HamanoMay 19, 2021
  6. brian m. carlsonMay 19, 2021
  7. Junio C HamanoMay 19, 2021
  8. Ævar Arnfjörð BjarmasonMay 19, 2021
  9. Felipe ContrerasMay 19, 2021
  10. brian m. carlsonMay 21, 2021
  11. Felipe ContrerasMay 21, 2021
  12. Igor DjordjevicMay 21, 2021
  13. Felipe ContrerasMay 21, 2021
  14. Igor DjordjevicMay 21, 2021
  15. Felipe ContrerasMay 21, 2021
  16. Igor DjordjevicMay 22, 2021
  17. Felipe ContrerasMay 22, 2021
  18. Igor DjordjevicMay 23, 2021
  19. Felipe ContrerasMay 23, 2021
  20. Igor DjordjevicMay 21, 2021
  21. Junio C HamanoMay 21, 2021
  22. Ævar Arnfjörð BjarmasonMay 19, 2021
  23. Jeff KingMay 19, 2021
  24. Felipe ContrerasMay 19, 2021
  25. Felipe ContrerasMay 19, 2021
  26. Felipe ContrerasMay 19, 2021
  27. brian m. carlsonMay 20, 2021
  28. Junio C HamanoMay 20, 2021
  29. Felipe ContrerasMay 20, 2021
  30. Junio C HamanoMay 20, 2021
  31. Felipe ContrerasMay 20, 2021
  32. Felipe ContrerasMay 20, 2021
  33. Felipe ContrerasMay 19, 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.