I know that git supports some "basic" named colors: normal, black, red, green, yellow, blue, magenta, cyan and white (see e.g. this SO question).
My question: can I change the actual values of these named colors, e.g. make the blue brighter? Note I don't mean change the colors of every single git command, just the default interpretation of colors.
More specifically, if I could get them to match my LS_COLORS, that would be neat.
CodePudding user response:
Git's color values are for talking to a terminal emulator, the words map to standard color requests.
Git translates the color values you give to your terminal's standard request for them. You say you want green
, git translates that to the terminal's request for slot 2, and the terminal displays whatever you've configured it to display for that.
There's no additional layer of indirection, you say what colors and attributes you want. You can specify which specific colors get used in various circumstances, e.g. for whitespace errors or very old changes in blame output or whatever, see the docs, but if you want to build some abstraction layer between what you say and what you mean you get to build that yourself and make it ask Git for what you mean instead of just asking Git yourself.
CodePudding user response:
Git allows you to specify colours as one of three ways: a name, a 256-bit colour value, or a hex value. If you use the name, or you use one of the first 16 colours of the 256 colour values (0-15), then you're asking for the terminal default colour of that type. That will be set to whatever your terminal happens to be set to, and as you can see on Wikipedia, the defaults for various terminals differ greatly.
If your terminal supports 256 colours (which most terminal emulators do these days), then you can use the other 240 colour numbers and you'll generally get a repeatable colour, since those values are typically fixed. Similarly, if your terminal supports true colour (not all do), then you can use a hex value as well, which will of course be fixed.
If you have certain values in your LS_COLORS
, you can run dircolors -p
to see an explanation of what the default values mean; most of the attributes there correspond to various options you can specify and that are documented in git config --help
. You may find that if you're looking for the brighter variant of the colour, that brightblue
may be what you're looking for.