2

I'm trying to customize the colors for the git info added to the prompt by posh-git, but it's not working. I have the following line in my profile:

$GitPromptSettings.DefaultForeGroundColor = 'Yellow'

And that works, if I change Yellow to Green I see the result right after I reload my profile. But other settings don't seem to work: for example, if I add the following line to my profile

$GitPromptSettings.BranchForegroundColor = 'DarkGreen'

...nothing happens, the branch foreground color stays the way it's declared in GitPrompt.ps1 (Cyan). Same thing with almost all the other GitPromptSettings colors.

I've also tried changing the settings in GitPrompt.ps1 and that didn't work either, except for DefaultForegroundColor, any other change I make to the prompt color settings in that file is ignored. What am I doing wrong?

2
  • Not sure, but browsing the help here, I found this: Note: Setting the ForegroundColor to a color name, other than one of the standard ConsoleColor names, only works on Windows. On Windows, posh-git uses the [System.Drawing.ColorTranslator]::FromHtml(string colorName) method to parse a color name as an HTML color. For a complete list of HTML colors, see this W3Schools page. Jan 24, 2021 at 1:21
  • The problem is not with the color names, I'm using the standard ConsoleColor names, as strings ('Yellow', "Green", etc.) or explicit types ([ConsoleColor]::Yellow,...etc.), the results are the same. If I use an invalid name (like 'Orange' for example), the script fails and the prompt reverts to the PowerShell default ("PS>").
    – Sam
    Jan 24, 2021 at 10:53

0

You must log in to answer this question.

Browse other questions tagged .