为什么PowerShell显示“DarkYellow”文本不正确? [英] Why does PowerShell display "DarkYellow" text improperly?

查看:214
本文介绍了为什么PowerShell显示“DarkYellow”文本不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Write-Host cmdlet更改提示的颜色,我注意到 DarkYellow 颜色不显示为任何种类的黄色,而是一个灰色!这里是所有颜色的测试

I'm using the Write-Host cmdlet to change the color of my prompt and I noticed that the DarkYellow color was not displaying as any sort of yellow, but as a gray! Here's a test of all the colors

PS> 0..15 | %{ Write-Host "Hello, world!" -ForegroundColor $_ }



我通过使用错误值得到了所有枚举值的列表



I got a list of all the enum values by using a bad value

PS> Write-Host "Hello, World!" -ForegroundColor foo




Black,DarkBlue,DarkGreen,DarkCyan,DarkRed,DarkMagenta ,DarkYellow,Gray,DarkGray,Blue,Green,Cyan,Red,Magenta,Yellow,White

Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White

控制台颜色某种程度上对应于此控制台窗口/快捷方式的设置,对不对?因此, DarkYellow 将是这个第七个,它肯定看起来灰色。

And I realized that this list of "console colors" somehow corresponds to the settings for this console window/shortcut, right? So, DarkYellow would be this 7th one in and it sure looks gray.

ForegroundColor System.ConsoleColor 和这些控制台快捷方式设置?为什么暗黄色显示为灰色开箱即用?我应该改吗?

What's the connection between ForegroundColor, System.ConsoleColor, and these console shortcut settings? Why is dark yellow displaying as gray "out of the box"? Should I change it? Will this change every console on my system or just this shortcut?

为什么控制台在Windows上如此精彩?

Why are consoles so finnicky on Windows?!

我在Windows 7 Pro SP1 64位,我从开始菜单启动Windows PowerShell快捷方式。

I'm on Windows 7 Pro SP1 64-bit and I'm launching the "Windows PowerShell" shortcut from the Start Menu.

推荐答案

我没有确切的答案,但我有一些工作!我做了一些研究(谢谢,Jason Shirk),发现 System.ConsoleColor 只是一个索引到颜色表,必须由

I don't have the exact answers, but I have something that kind of works! I did some research (thanks, Jason Shirk) and found that System.ConsoleColor is just an index into the color table, which must be represented by this

>

文档确实提到 DarkYellow 应该是 ocher (RGB:204,119,34)。

The documentation does mention that DarkYellow is supposed to be "ochre" (RGB: 204, 119, 34).


| DarkYellow  | The color dark yellow (ochre). |


从应用程序的左上角窗口菜单中选择您将看到通用的控制台Windows属性(如上所示),它将修改任何 ConsoleWindowClass 类型窗口。

Choose "Defaults" from the application's top-left window menu and you'll see the generic "Console Windows Properties" (like above), which will modify any ConsoleWindowClass type window.

选择屏幕文本选项,您会注意到它设置为使用 DarkYellow 的位置的值。我不知道他们为什么不用它旁边的 Gray DarkGray 单击第七个框( DarkYellow 的索引),并将其更改为ocher的RGB值。然后,将屏幕文本设置为 Gray DarkGray (除非你真的希望赭石前景文本默认) 。

Pick the "Screen Text" option and you'll notice it's set to use the value in DarkYellow's spot. I don't know why they didn't use Gray or DarkGray right next to it! Click on the 7th box (the index for DarkYellow) and change it to ochre's RGB value. Then, set the "Screen Text" to the Gray or DarkGray (unless you really want ochre foreground text by default).

所有的命令提示符,PowerShell和Git Bash(mingw)控制台都会被改变(我的)。

All of your Command Prompt, PowerShell, and Git Bash (mingw) consoles will be changed (mine were).

我从运行对话框的PowerShell提示中遇到了一些麻烦。它采取的颜色,但不是我的一些其他设置(物理和缓冲区大小等)。我最后使用 scoop 安装 concfg

I did have a little trouble with the PowerShell prompt from the "run" dialog. It took the colors, but not some of my other settings (physical and buffer size, etc). I ended up using scoop to install concfg

PS> scoop install concfg
PS> scoop install sudo

并导出我的控制台设置

PS> concfg export > ~\.consolerc

并将它们导入我的行为不当的提示中(您可以使用 sudo ,也来自scoop,或者只是启动管理员提示)

and imported them into my misbehaving prompt with prejudice (you can use sudo, also from scoop, or just launch an admin prompt)

PS> sudo concfg import ~\.consolerc

实际上,concfg似乎导出一切,颜色表值和选择!这里是我的配置(颜色部分)的部分转储。

And, actually, concfg seemed to export everything, the color table values and the selections! Here's a partial dump of my configuration (the color parts)

{
    "popup_colors":  "cyan,white",
    "dark_gray":  "#808080",
    "screen_colors":  "gray,dark_magenta",
    "dark_green":  "#008000",
    "blue":  "#0000ff",
    "dark_yellow":  "#cc7722",
    "red":  "#ff0000",
    "magenta":  "#ff00ff",
    "dark_red":  "#800000",
    "yellow":  "#ffff00",
    "dark_magenta":  "#012456",
    "cyan":  "#00ffff",
    "green":  "#00ff00",
    "dark_blue":  "#000080",
    "gray":  "#c0c0c0",
    "white":  "#ffffff",
    "black":  "#000000",
    "dark_cyan":  "#008080"
}

这篇关于为什么PowerShell显示“DarkYellow”文本不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆