Reputation: 62736
I use PowerShell with posh-git. According to https://app.pluralsight.com/library/courses/git-advanced-tips-tricks/table-of-contents the following command line
git log --pretty='%Cred%h%Creset | %C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %C(cyan)[%an]%Creset'
should display the branch reference in yellow. However, it does not work:
The red, green and cyan do show up, but not the yellow, which should color the string (HEAD -> master, origin/master)
. I checked and it does not work if I try to use yellow for other parts of the log too. It is as if PowerShell is unable to render yellow.
Here is the snapshot from the PluralSight video:
In the snapshot the shell is zsh and the OS is Unix or Linux, but I do not see any reason why PowerShell should not be able to display yellow.
What is wrong?
Upvotes: 1
Views: 488
Reputation: 62736
I fixed all my issues with Powershell colors using the following script.
FixPowershellColors.ps1
reg import $PSScriptRoot\Windows10ConsoleColors.reg
$WindowsPowerShellShortcutDir = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell"
$UserPinnedTaskBarDir = "$env:USERPROFILE\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
$sh = New-Object -ComObject WScript.Shell
@(
"Windows PowerShell",
"Windows PowerShell (x86)",
"Windows PowerShell ISE",
"Windows PowerShell ISE (x86)"
) |% {
$ShortcutName = $_
@(
"$WindowsPowerShellShortcutDir",
"$UserPinnedTaskBarDir"
) |? { Test-Path "$_\$ShortcutName.lnk" } |% {
$ShortcutPath = "$_\$ShortcutName.lnk"
$Shortcut = $sh.CreateShortcut($ShortcutPath)
$TargetPath = $Shortcut.TargetPath
del $ShortcutPath
$Shortcut = $sh.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()
}
}
"Reopen PowerShell console to see the changes"
It takes the first line to update the Powershell colors from Windows10ConsoleColors.reg
and the rest is dedicated to refreshing the various Powershell shortcuts.
Windows10ConsoleColors.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:000c0c0c
"ColorTable01"=dword:00c50f1f
"ColorTable02"=dword:0013a10e
"ColorTable03"=dword:00c19c00
"ColorTable04"=dword:000037da
"ColorTable05"=dword:00881798
"ColorTable06"=dword:003a96dd
"ColorTable07"=dword:00cccccc
"ColorTable08"=dword:00767676
"ColorTable09"=dword:00e74860
"ColorTable10"=dword:0016c60c
"ColorTable11"=dword:00f9f1a5
"ColorTable12"=dword:003b78ff
"ColorTable13"=dword:00b4009e
"ColorTable14"=dword:0061d6d6
"ColorTable15"=dword:00f2f2f2
So, as long as your powershell shortcuts are in the well-known locations the script updates them all after which you just need to reopen the console window.
Upvotes: 0
Reputation: 1
i had the same issue, and i switched to using bold colors which worked for me.
try this (i also changed red to bold as it is more visible that way):
git log --pretty="%C(red bold)%h%Creset | %C(yellow bold)%d%Creset %s %Cgreen(%cr)%Creset %C(cyan)[%an]%Creset"
Upvotes: 0