如何重置powershell颜色?

时间:2015-11-22 20:00:36

标签: powershell colors

我改变了powershell的颜色,现在我无法改变输入文本的颜色,总是黄色

我改变了背景的颜色和文字的颜色

changing colors

背景颜色已正确更改,但在显示文字中颜色仍为黄色。

changed

我可以做些什么来重置颜色吗?

10 个答案:

答案 0 :(得分:79)

这会重置控制台颜色(例如,[Console] :: BackgroundColor):

[Console]::ResetColor()

答案 1 :(得分:8)

我意识到这是一个老问题,但我在谷歌找到了它并有另一个解决方案。

Set-PSReadlineOption -TokenKind Command -ForegroundColor Black

Source

这会将输入文本更改为黑色。可用的颜色选择如下:

  • 黑色
  • DarkBlue
  • DarkGreen
  • DarkCyan
  • DarkRed
  • DarkMagent
  • DarkYellow
  • 灰色
  • 深灰
  • 绿色
  • 青色
  • 红色
  • 品红
  • 黄色

您可以通过将其添加到个人资料中来保持此状态。它足以将命令附加到文件的末尾。

在我的情况下,个人资料位于:C:\Users\Billy\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

要获取PS个人资料类型的位置:

$profile

如果此文件不存在,您可以使用以下命令创建它:

New-item –type file –force $profile

source

要查看个人资料中的当前设置,请使用:

Get-PSReadlineOption

source

答案 2 :(得分:5)

@dhobbs在评论中指出

编辑,这不再是PowerShell 6中的一个选项:https://docs.microsoft.com/en-us/powershell/module/PSReadline/Set-PSReadlineOption?view=powershell-6

可以使用以下命令将PowerShell控制台颜色重置为默认值:

Set-PSReadlineOption -ResetTokenColors 

此处的文档:https://msdn.microsoft.com/en-us/powershell/reference/5.1/psreadline/set-psreadlineoption

将该行添加到PowerShell配置文件中,以便每次打开PowerShell控制台时都运行该命令。要查看PowerShell配置文件的位置,请从PowerShell控制台键入:

$profile

答案 3 :(得分:2)

通过右键单击标题栏并单击“属性”看到的颜色实际存储在{ "x": "this is x", "y": "this is x", "z": "this is z" } 部分的快捷方式文件中。您可以删除快捷方式并重新创建它,也可以使用十六进制编辑器更改值。除此之外,没有“重置”功能。对于正常的命令提示符也是如此。

010 Editor Screenshot

答案 4 :(得分:0)

你指的是ISE吗?如果是这样,请选择工具>选项,您将看到更改背景和前景色的选项。从这里您可以选择“恢复默认值”

答案 5 :(得分:0)

您可以使用此工具备份颜色。

https://github.com/lukesampson/concfg/blob/master/README.md

它提供了完美的预设设置。

答案 6 :(得分:0)

从鑫偷走了,但我无法发表评论,所以您将不得不接受

[Console]::ResetColor()

然后清除屏幕以使更改生效。

clear

我认为这是bucky先前回答的问题。

希望这对您有帮助!

答案 7 :(得分:0)

我刚刚在今天(2019年6月)找到了上述答案之一中链接到的MS页面

ms fix for powershell

我只是将他们的第一个建议-这个-粘贴到了powershell中,现在看来还可以:

 Set-PSReadLineOption -Colors @{

#使用ConsoleColor枚举      “错误” = [ConsoleColor] :: DarkRed

#24位颜色转义序列      “ String” =“ $([char] 0x1b)[38; 5; 100m”

#RGB值      “命令” =“#8181f7”     }

尽管我不确定100%,因为我设置的白色背景仍然存在。但是黄色已经消失了,这是肯定的。

这是以后的编辑。我回来了,试图将所有内容放到代码块中,而不仅仅是第一行,但是我不知道该怎么做。

要点是,必须将所有代码放在大括号之间,并且#标记行是注释。不幸的是,注释和代码都在同一行上,我无法修复。注释在“”文本开始的地方结束。

如果我把评论删除掉,会更简单。无论如何..2019年6月,这是唯一对我有用的技术。

p.s。我现在发现关闭后修复无法正常工作。重新启动后,我必须再次做一次。

答案 8 :(得分:0)

我发现这可行。我认为是用户577111的回答。我们需要将所有这些内容放入PS。

Set-PSReadLineOption -Colors @{

使用ConsoleColor枚举     “错误” = [ConsoleColor] :: DarkRed  24位颜色转义序列     “ String” =“ $([char] 0x1b)[38; 5; 100m”  RGB值     “ Command” =“#8181f7”}

答案 9 :(得分:0)

答案

对于原始问题,黄色文字是有意的。它是PSReadLine模块中的语法着色。此颜色是Windows PowerShell的(新)默认设置。

PetSerAl mentioned一样,Remove-Module PSReadline将删除该会话的突出显示。如果要永久删除PSReadLine,请使用以下PowerShell命令修改PowerShell profile

if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
}
Add-Content $PROFILE "`nRemove-Module PSReadline"

如果要更改语法颜色,请遵循Set-PSReadLineOption的文档。具体来说,请查看名称中带有“颜色”的参数。并确保将文档中的版本设置为与your PowerShell version相匹配。 (Windows 10版本1809及更高版本uses the PowerShell 6.0 syntax是一个例外。)

Where to change the PowerShell version on the Microsoft documentation Web site.

示例

例如,如果要将命令文本颜色从黄色更改为洋红色,则可以使用PowerShell 6语法(使用PowerShell 6语法)输入以下内容:

Set-PSReadLineOption -Colors @{
"Command" = [ConsoleColor]::Magenta
}

请记住,这是临时的,必须将其添加到PowerShell配置文件中才能永久使用。


修复快捷方式颜色

另一方面,如果您在原始问题中看到了快捷方式属性屏幕截图,并想到:“嘿,我弄乱了我的快捷方式颜色”,那么此答案适合您。

Drew Chapin points out一样,解决此问题的一种简单方法是重新创建快捷方式。但是,如果您仅创建一个新的快捷方式并将其指向powershell.exe,则将获得黑白外壳。

PowerShell in black and white.

如果您想要漂亮的蓝白色外壳,则必须做其他事情。

PowerShell with default blue color.

在创建新的快捷方式之前,最好先清除引起问题的快捷方式。如果您将它们固定在某处,并且不确定实际的快捷方式文件位于何处,则下面是一些常见的位置。将这些路径一次输入一个到文件资源管理器的地址栏中,然后四处浏览。在某些情况下,我提供了指向父文件夹的路径,建议您使用文件资源管理器中的搜索功能在子文件夹中搜索“ powershell”:

shell:Common Desktop
shell:Common Start Menu    search for "powershell"
shell:Common Startup
shell:Quick Launch
shell:Start Menu           search for "powershell"
shell:Startup
shell:User Pinned          search for "powershell"

Typing a shell command into the File Explorer address bar.

Searching for "powershell" in a parent folder.

创建新的PowerShell快捷方式

回到新鲜的快捷方式,“自己动手”解决方案是创建一个新的Windows用户,并从其开始菜单复制PowerShell快捷方式。您可以通过打开文件资源管理器并导航到

来找到快捷方式。
shell:Start Menu\Programs\Windows PowerShell

如果您不想麻烦或无法创建新用户,我创建了一个PowerShell脚本,它将为您创建快捷方式。 Change directory到要在其中创建快捷方式的位置。然后将以下命令粘贴到PowerShell中,或者将其保存并执行为.ps1文件。请记住,快捷方式将在current working directory中创建。

示例

  1. 打开PowerShell。
  2. 在“开始”菜单中将目录更改为PowerShell文件夹。
set-location "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell"

  1. 删除现有的快捷方式(如果它们给您带来了问题)。
remove-item .\*.lnk -whatif
  1. 运行以下脚本。
# Base64-encoded PowerShell .lnk files from a new Windows user profile. 
# Windows 10.0.17763.615 en-US

$windowsPowerShellLnk = @"
TAAAAAEUAgAAAAAAwAAAAAAAAEbfAgAAIAAAAJuvlrfNas0Bm6+Wt81qzQGAHQKo3WrNAQDwBgAAAAAAAQAAAAAAAAAAAAAAAAAAAPEBFAAfUOBP0CDqOmkQotgIACswMJ0ZAC9DOlwAAAAAAAAAA
AAAAAAAAAAAAAAAUgAxAAAAAADHQgKwMABXaW5kb3dzADwACAAEAO+++kDALMdCArAqAAAAHxAAAAAAAQAAAAAAAAAAAAAAAAAAAFcAaQBuAGQAbwB3AHMAAAAWAFYAMQAAAAAAx0JdBTAAU3lzdG
VtMzIAAD4ACAAEAO+++kDBLMdCXQUqAAAAChgAAAAAAQAAAAAAAAAAAAAAAAAAAFMAeQBzAHQAZQBtADMAMgAAABgAaAAxAAAAAAD6QKBBEABXSU5ET1d+MQAAUAAIAAQA7776QKBB+kCgQSoAAAC
HHQAAAAABAAAAAAAAAAAAAAAAAAAAVwBpAG4AZABvAHcAcwBQAG8AdwBlAHIAUwBoAGUAbABsAAAAGABKADEAAAAAALhC660UAHYxLjAAADYACAAEAO+++kCgQbhC660qAAAAiB0AAAAAAQAAAAAA
AAAAAAAAAAAAAHYAMQAuADAAAAAUAGgAMgAA8AYA+kCaGiAAcG93ZXJzaGVsbC5leGUAAEoACAAEAO+++kBXC/pAVwsqAAAA//kAAAAAAQAAAAAAAAAAAAAAAAAAAHAAbwB3AGUAcgBzAGgAZQBsA
GwALgBlAHgAZQAAAB4AAABuAAAAHAAAAAEAAAAcAAAAMwAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJQB3AGkAbgBkAGkAcgAlAFwAcwB5AHMAdwBvAHcANgA
0AFwAVwBpAG4AZABvAHcAcwBQAG8AdwBlAHIAUwBoAGUAbABsAFwAdgAxAC4AMABcAFAAbwB3AGUAcgBTAGgAZQBsAGwAXwBJAFMARQAuAGUAeABlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
"@


# Decode and save to file.  

[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell.lnk",           ([System.Convert]::FromBase64String($windowsPowerShellLnk)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell ISE.lnk",       ([System.Convert]::FromBase64String($WindowsPowerShellISE)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell (x86).lnk",     ([System.Convert]::FromBase64String($WindowsPowerShellx86)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell ISE (x86).lnk", ([System.Convert]::FromBase64String($WindowsPowerShellISEx86)))

# Trailing comment as a selection-aid for Stack Overflow readers. 

此外,我对到目前为止的话题有一些评论。

为重设PSReadLine颜色而设置的答案假定这些颜色已永久设置为非默认值。这不太可能,因为您必须对PowerShell配置文件进行更改。而且您会知道是否更改了个人资料。

这里的另一个问题是 yellow 是默认PSReadLine方案中命令的预期颜色。因此,任何重设只会使原始海报具有相同的黄色文本。

对于非默认颜色,一个简单的测试是关闭并重新打开PowerShell。如果在键入命令时文本为黄色,则可能没问题;困扰您的一切都仅限于该PowerShell会话,现在不存在了。

如果要检查PowerShell配置文件中是否有任何(永久)Set-PSReadLineOption命令,请输入

notepad $profile

进入PowerShell,并浏览打开的文本文件。如果收到错误,则说明您没有个人资料(这不是问题)。