Andrew Shepherd
Andrew Shepherd

Reputation: 45272

Git colors - branch description text

It's straightforward to change the colors that the git shell uses. For example, if I want to change the color of untracked files from red to 'red bold', I type:

git config --local --replace color.status.untracked "red bold"

The trick is to know the setting name for each display element.

The command prompt always tells you the current branch you're on, and a summary of the status information. The color of the summary is red. I want it to be a different color.

What is the setting name that represents the summary text element?

enter image description here

Upvotes: 1

Views: 1372

Answers (1)

Andrew Shepherd
Andrew Shepherd

Reputation: 45272

It appears that the prompt colors are set via a different mechanism than the outputs colors.

If, on the powershell commandline, you type

$global:GitPromptSettings

You will see the settings relating to how the git prompt displays. Some of these values:

BranchBehindForegroundColor            : Red
RepositoriesInWhichToDisableFileStatus : {}
BranchForegroundColor                  : Cyan
BranchBehindAndAheadBackgroundColor    : Black
BranchBehindAndAheadForegroundColor    : Yellow
BeforeText                             :  [
WorkingBackgroundColor                 : Black
WorkingForegroundColor                 : DarkRed
EnableWindowTitle                      : posh~git ~ 
BranchBehindBackgroundColor            : Black
BeforeIndexText                        : 
ShowStatusWhenZero                     : True
DelimText                              :  |
BeforeBackgroundColor                  : Black
UntrackedForegroundColor               : DarkRed
IndexForegroundColor                   : DarkGreen

The setting I needed to change here was WorkingForegroundColor

I could test the results of changing this value straight away by typing:

$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Green

Useful blog entries on this subject:

Upvotes: 1

Related Questions