Skip to content

Instantly share code, notes, and snippets.

@SyntaxC4
Last active December 30, 2021 09:10
Show Gist options
  • Select an option

  • Save SyntaxC4/7933408 to your computer and use it in GitHub Desktop.

Select an option

Save SyntaxC4/7933408 to your computer and use it in GitHub Desktop.
Changing Colors in Posh-Git

Changing color settings in Poshgit

This set of documentation takes an assumption that Poshgit was installed using Chocolatey, which installs the powershell Modules in a different directory than the expected defaults.

  1. Navigate to the Poshgit Install Directory

    • [Chocolatey] C:\tools\Poshgit\dahlbyk-posh-git-9d624ca\
    • [Local User] %UserProfile%\Documents\WindowsPowerShell\Modules\Poshgit
    • [System] %windir%\System32\WindowsPowerShell\Modules\Poshgit
  2. Right-Click on GitPrompt.ps1 and select Edit

  3. Between line 5 and 39 you will find all of the colour settings

         DefaultForegroundColor    = $Host.UI.RawUI.ForegroundColor
     
         BeforeText                = ' ['
         BeforeForegroundColor     = [ConsoleColor]::Yellow
         BeforeBackgroundColor     = $Host.UI.RawUI.BackgroundColor
         DelimText                 = ' |'
         DelimForegroundColor      = [ConsoleColor]::Yellow
         DelimBackgroundColor      = $Host.UI.RawUI.BackgroundColor
     
         AfterText                 = ']'
         AfterForegroundColor      = [ConsoleColor]::Yellow
         AfterBackgroundColor      = $Host.UI.RawUI.BackgroundColor
     
         BranchForegroundColor       = [ConsoleColor]::Cyan
         BranchBackgroundColor       = $Host.UI.RawUI.BackgroundColor
         BranchAheadForegroundColor  = [ConsoleColor]::Green
         BranchAheadBackgroundColor  = $Host.UI.RawUI.BackgroundColor
         BranchBehindForegroundColor = [ConsoleColor]::Red
         BranchBehindBackgroundColor = $Host.UI.RawUI.BackgroundColor
         BranchBehindAndAheadForegroundColor = [ConsoleColor]::Yellow
         BranchBehindAndAheadBackgroundColor = $Host.UI.RawUI.BackgroundColor
     
         BeforeIndexText           = ""
         BeforeIndexForegroundColor= [ConsoleColor]::DarkGreen
         BeforeIndexBackgroundColor= $Host.UI.RawUI.BackgroundColor
     
         IndexForegroundColor      = [ConsoleColor]::DarkGreen
         IndexBackgroundColor      = $Host.UI.RawUI.BackgroundColor
     
         WorkingForegroundColor    = [ConsoleColor]::DarkRed
         WorkingBackgroundColor    = $Host.UI.RawUI.BackgroundColor
     
         UntrackedText             = ' !'
         UntrackedForegroundColor  = [ConsoleColor]::DarkRed
         UntrackedBackgroundColor  = $Host.UI.RawUI.BackgroundColor
     
  4. Here us a description of each of the foreground colours:

    Setting Name Description Default Colour
    BeforeForegroundColor The first character added to the commandline when a `.git` directory is detected Yellow
    DelimForegroundColor Yellow
    AfterForegroundColor
    BranchForegroundColor
    BranchAheadForegroundColor
    BranchBehindForegroundColor
    BranchBehindAndAheadForegroundColor
    BeforeIndexForegroundColor
    IndexForegroundColor
    WorkingForegroundColor
    UntrackedForegroundColor
@rzippo
Copy link

rzippo commented Mar 31, 2018

Should add a paragraph about when are changes applied.

@dikleins
Copy link

dikleins commented Apr 2, 2020

I tried that but still see dark red output for not staged and untracked files. That output is unreadable.
image

@ulty4life
Copy link

You can edit the posh-git files to achieve this, or you could override the posh-git variable values in your powershell profile script after importing posh-git. This way you don't have to modify posh-git, and you can make your settings into a portable file.

@SkybuckFlying
Copy link

Is it possible to make the git commit hashes in git log --graph --all yellow/gold instead of white ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment