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

Re: Coloring

From
Jeff King <peff@peff.net>
Date
May 31, 2017, 21:04 UTC
Message-ID
<20170531210448.6kolid5umzyasxnc@sigill.intra.peff.net>
In-Reply-To
<CAD1ypiWOcKaLJJzZC=gw75EDFnw_1ZqC94B5p9i722T-sijN1Q@mail.gmail.com>
On Wed, May 31, 2017 at 11:33:31AM -0700, Irving Rabin wrote:
Show 12 quoted lines
> Specifically, if the field is supposed to be white, it doesn't mean it
> should be literally 0xFFFFFF. It should be the color that I have
> configured as White color for my console emulator.
> 
> I like light-screen terminals, and I configure my ANSI colors in the
> way that they are clearly visible on the background and clearly
> distinct between themselves. In my terminal settings background is
> light-yellow, Black is black, Yellow is brown, Red is dark red,
> Magenta is purple and White is dark gray. I set it once and I can use
> it everywhere - all Unix commands work correctly, I can edit
> highlighted source code in Vim, and all my color settings are
> respected.

Git outputs ANSI color codes, which are interpreted by your terminal. You _can_ configure Git to send 24-bit color codes if your terminal supports it, but by default it uses the traditional set of limited color and attribute codes.

What does running the following snippet in your shell look like?
-- >8 --
while read name code; do
	printf '\033[%sm%s\033[m\n' "$code" "$name"
done <<-\EOF
normal
bold 1
red 31
green 32
yellow 33
blue 34
magenta 35
cyan 36
bold-red 1;31
bold-green 1;32
bold-yellow 1;33
bold-blue 1;34
bold-magenta 1;35
bold-cyan 1;36
EOF
-- 8< --

If any of the colors are not what you expect, is there a pattern? E.g., I wouldn't be surprised if "bold" shows up as bright white. In many modern terminal emulators, the bold variants need to be configured separately from the non-bold ones, and default to lighter variants of their non-bold counterparts. The solution there would be to check your terminal emulator config.

If it does all look as you'd expect, try adding "| less -R" to the end of the "done <<-\EOF" line. Most of Git's output goes through that pager (though I _think_ it's mostly just passing through the ANSI codes, so it wouldn't have any effect).

-Peff
Previous: Samuel LijinNext: Irving Rabin
Message 3 of 5 in “Coloring”
  1. Irving RabinMay 31, 2017
  2. Samuel LijinMay 31, 2017
  3. Jeff KingMay 31, 2017
  4. Irving RabinMay 31, 2017
  5. Samuel LijinMay 31, 2017

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.