PowerShell and Git for the colorblind
posted in dev-setup on • by Wouter Van Schandevijl • last updated onMy PowerShell, Posh-Git and .gitconfig color configuration because of some red-green troubles with the default configurations.
in the land of the blind, the one-eyed man is king
PowerShell
List current colors
$host.PrivateData |
Get-Member -MemberType Property |
Select-Object Name,@{label='Value';exp={$host.PrivateData.($_.Name)}} |
Format-Table -AutoSize
With just changing how Errors are displayed, everything is readable, for me, with Cmder.
$host.PrivateData.ErrorBackgroundColor = 'Red'
$host.PrivateData.ErrorForegroundColor = 'Yellow' # or: "DarkMagenta"
Posh-Git
List current configuration
$GitPromptSettings
v0.x
My changes
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Yellow
$global:GitPromptSettings.BranchForegroundColor = [ConsoleColor]::Green
Get possible colors
[ConsoleColor].GetEnumNames()
- Gray, Blue, Green, Cyan, Red, Magenta, Yellow, White
- Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, DarkGray
v1.x
Some breaking changes…
$GitPromptSettings.DefaultPromptPath.ForegroundColor = 'White'
$GitPromptSettings.LocalWorkingStatusSymbol.ForegroundColor = 'Yellow'
$GitPromptSettings.WorkingColor.ForegroundColor = 'Yellow'
$GitPromptSettings.BranchAheadStatusSymbol.ForegroundColor = 'Green'
$GitPromptSettings.BranchBehindStatusSymbol.ForegroundColor = 'DarkMagenta'
$GitPromptSettings.BranchBehindAndAheadStatusSymbol.ForegroundColor = 'Yellow'
Colors are interpreted with
System.Drawing.ColorTranslator.FromHtml()
Git
List current colors
git config --list | Where-Object {$_ -Like "color*"}
~/.gitconfig
Available colors: normal, black, red, green, yellow, blue, magenta, cyan, or white
Second optional color param values: bold, dim, ul (underline), blink, and reverse (swap foreground and background)
[color "branch"]
current = yellow
local = white
remote = magenta
[color "status"]
header = white
changed = magenta bold
untracked = magenta bold
unmerged = magenta reverse
added = yellow
branch = white
[color "diff"]
meta = blue white
frag = normal bold
old = magenta bold
new = green bold
Advantages
Updates
- 22 August 2018 : Update for Posh-Git v1
Category:
dev-setup
Tags:
powershell
git