Skip to content

Latest commit

 

History

History
132 lines (99 loc) · 2.79 KB

2017-04-21-powershell-and-git-for-the-colorblind.md

File metadata and controls

132 lines (99 loc) · 2.79 KB
layout author title date categories img tags toc last_modified_at updates redirect_from
post
Wouter Van Schandevijl
PowerShell and Git for the colorblind
2017-04-21 15:00:00 +0200
dev-setup
url
colorblind.png
powershell
git
title icon
Colorization
icon-git
2018-08-22 00:00:00 +0200
date desc
2018-08-22 00:00:00 +0200
Update for Posh-Git v1
/blog/productivity/powershell-and-git-for-the-colorblind/

My 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

Nailed it!