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

Re: [PATCH] help: colorize man pages

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 21, 2021, 00:58 UTC
Message-ID
<YKcFrbuuJrWAxXgm@camp.crustytoothpaste.net>
In-Reply-To
<87lf8bqdv0.fsf@evledraar.gmail.com>
On 2021-05-19 at 08:41:44, Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> It also doesn't seem to me to satisfy their FAQ point #1, i.e. users who
> actually want no color at all can just set TERM=dumb, and we support
> that. The proposed patch is the same as having TERM=dumb set.
> 
> This NO_COLOR=1 actually means something like "I do support colors, so
> show them if it's important, but don't color things willy-nilly".

I don't agree. The way I read it is that it means that if your program receives colored input, it is not obligated to strip it out, but it is obligated not to add any. For example, if less supported NO_COLOR, then it would render color it received on stdin, but not color its status bars.

For Git, this means that we shouldn't add color, but if a user has stuffed some ANSI escape sequences in their formatting string, we'll pass them through.

> So it would be incorrect to map it to either color.ui=never or
> color.ui=always (as "auto" will implicitly do). We'd need a new knob to
> control the granularity of coloring, something like
> color.ui=conservative.
No, I think in the context of Git it means, "I don't want color."
Show 5 quoted lines
> I wasn't against NO_COLOR before, but after writing the above I think I
> am. I initially assumed that it was some redundant and more "friendly"
> way of setting TERM=dumb, but rather it's some entirely subjective way
> for every program to decide if their UI elements are "text-editor"-like
> or "status bar"-like enough to warrant coloring.

TERM=dumb turns off having an addressable cursor. Git uses a pager for a lot of output, so that's a completely undesirable way to indicate you don't want color, since it makes scrolling backwards impossible (and may even disable the pager, but I haven't checked). For a text editor, TERM=dumb means you're stuck with ex or ed.

NO_COLOR=1 says, "I don't want color, but I have a fully functional terminal I would like to use, thank you."

I should point out that I think you've misread the text about status bars. It says this:

  It is reasonable to configure certain software such as a text editor
  to use color or other ANSI attributes sparingly (such as the reverse
  attribute for a status bar) while still desiring that other software
  not add color unless configured to. It should be up to the user
  whether color is used, not the software author.

In other words, I think in this case, the user has opted to configure their editor as they like it and invoke it without NO_COLOR, but has instructed other programs to not add color with NO_COLOR.

Note also that the explanation specifically mentions the reverse attribute, which TERM=dumb will suppress.

> That's "against" in the sense that if git supported it I wouldn't care
> much, and wouldn't oppose a patch to implement it.
I will probably send a patch to implement it, just not tonight.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Previous: Felipe ContrerasNext: Felipe Contreras
Message 10 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.