在概要文件脚本中使用十六进制值设置Powershell颜色 [英] Setting Powershell colors with hex values in profile script

查看:265
本文介绍了在概要文件脚本中使用十六进制值设置Powershell颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以通过在我的配置文件中设置类似的东西来改变PowerShell控制台颜色:

I know I can change PowerShell console colors by setting in my profile something like:

$Host.UI.RawUI.BackgroundColor = "White"
Clear-Host

但是在Powershell控制台中,颜色选项卡,并手动修改标准16 ANSI颜色的RGB值。是否可以从配置文件脚本中设置标准颜色的十六进制或RGB值?例如设置我想有:

However in the Powershell Console one can go to the Color tab in Properties and modify the RGB values of the standard 16 ANSI colors manually. Is it possible to do set either hex or RGB values of the standard colors from the profile script? For instance setting I would like to have:

$Host.UI.RawUI.BackgroundColor = "#242424"  # Gray
Clear-Host


推荐答案

$ Host 对象。颜色表存储在注册表中。下面是配置默认PowerShell.exe以匹配blue配置的示例:

You can, but not via the $Host object. The color table is stored in the registry. Here is an example of a configuration of the default PowerShell.exe to match "blue" config:

Lee Holmes的Set-ConsoleProperties.ps

您将使用相同的名称,但颜色会有所不同。这就是默认PowerShell控制台是蓝色/灰色的原因。

You would use the same names, but the colors would be different. That's why the default PowerShell console is blue/gray.

这篇关于在概要文件脚本中使用十六进制值设置Powershell颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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