为什么PowerShell和Posh Git中没有黄色?

10

好的,在Git Bash中使用这个命令...

git log --pretty='%C(yellow)%h%Creset %s' --abbrev-commit

在 Git Bash 中,我得到了带有黄色提交 ID 和白色主题行的效果,但是在 Powershell(使用 Posh Git)中,我没有看到黄色的提交 ID(它是默认的白色)。

为什么?

1个回答

10

原来,PowerShell的控制台将System.ConsoleColor.DarkYellow呈现为白色:

[Enum]::GetValues([ConsoleColor]) | %{ Write-Host $_ -ForegroundColor $_ }

使用 bold yellow 代替,它将呈现为 System.ConsoleColor.Yellow

git log --pretty='%C(bold yellow)%h%Creset %s' --abbrev-commit

cygwin和 color.diff自动 color.status自动 color.branch自动 color.interactive true - Tim Jarvis
1
@Klas 我不确定你的意思?posh-git的颜色可以通过设置@GitPromptSettings属性进行配置,但默认情况下所有黄色都是“Yellow”而不是“DarkYellow”。 - dahlbyk
我的错。我在想git的输出,例如“git reflog”中的哈希值,但这当然不是posh-git的问题。我想我必须查看git-config(1)手册页面,以查找在Windows中设置为黄色的所有颜色设置。 - Klas Mellbourn
说实话,我会直接在Console2或ConEmu中托管PowerShell,因为它们使用更标准(且易于自定义)的颜色调色板。 - dahlbyk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接