Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

rzippo commented Mar 31, 2018

Should add a paragraph about when are changes applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.