Skip to content

Instantly share code, notes, and snippets.

@SyntaxC4
Last active December 30, 2021 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SyntaxC4/7933408 to your computer and use it in GitHub Desktop.
Save SyntaxC4/7933408 to your computer and use it in GitHub Desktop.
Changing Colors in Posh-Git

Changing color settings in Poshgit

  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 The character used to separate untracked changes from tracked changes in the current branch. Yellow
    AfterForegroundColor This is the last characted added to the commandline when a `.git` directory is detected Yellow
    BranchForegroundColor This is the colour which identifies your current branch Cyan
    BranchAheadForegroundColor This is the colour which identifies your current branch is ahead of any/all remote repositories Green
    BranchBehindForegroundColor This is the colour which indentifies your current branch is behind any/all remote repositories Red
    BranchBehindAndAheadForegroundColor This is the colour which identifies your current branch is both Ahead and Behind any remote repositories Yellow
    BeforeIndexForegroundColor DarkGreen
    IndexForegroundColor This is the colour of items which are being tracked in Git's index. DarkGreen
    WorkingForegroundColor This is the colour of items which are in your working directory and untracked by Git DarkRed
    UntrackedForegroundColor This is the colour of the indicator to notify when there are untracked changes DarkRed
@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