Search code examples
gitterminalprompt256color

Git Color UI support for 256 Colors?


I am trying to colour my Git output using my native XTerm 256 color palette. Is there anyway to do this? I can't seem to get it to work.

for example in .gitconfig.

[color]
  ui = auto
[color 'branch']
  local = colour33
  remote = colour46
  current = colour27

Etc.
I know this formatting works when you specify the various basic color terms; cyan, magenta, yellow, and attributes; dim, bright, ul, bold, etc.
But I just can't find anything in regards to using the full color palette available to a 256color terminal, without actually changing the 8 basic color terms themselves, in the actual pallete.
There isn't anything in the documentation or manpages that I can find either.
I know different programs seem to use different syntax for specifying color, so I may just be using the wrong syntax or I am the only one who has ever wanted to do such a thing.

I am assuming git-config will only support those basic 8 colors with various attributes based on what the git-config man page is saying, so if this is not possible, is there a way to change those colors, in the terminals color palette BUT only for one program, like in this situation, Git? Maybe a perl script that exports those values only when git-config is referencing them, but unsets them soon as git-config is finished?

And no this is not too much trouble than its worth. I love my eyecandy in a terminal, and id do it myself if I could figure out a resource that explains something similar.


Solution

  • The syntax for the color is: [fg [bg]] [attr]...

    As for the colors, you can use the named ones (normal, black, red, green, yellow, blue, magenta, cyan, and white) or just a number of the color in the 256 palette without any prefix.

    The supported attributes are: bold, dim, ul, blink, and reverse.

    So your configuration might look like this (tested with git 1.8.5.3):

    [color "branch"]
        local = 33 
        remote = 46
        current = 27
    

    I have taken a look into the git source code to find the answer.