如何更改 powershell 终端颜色或完全关闭颜色编码

问题描述

我的眼睛很难看到 powershell 使用的彩虹色。我需要以某种方式获得一个 powershell 终端窗口,以在白色背景上用黑色文本显示所有内容(又名,错误消息、语法、输出等)。并且我需要在 Azure Cloud Shell 中执行此操作并“坚持”(这意味着如果我退出 cloud-shell 并返回它,终端窗口会自动正确设置)。

这可行吗?有人可以指出我的脚本或正确的命令来执行此操作吗?或者可能会指向我一些可访问性设置?

不胜感激!

账单

解决方法

首先你需要一个个人资料来编辑:

if ($false -eq (Test-Path $profile)){New-Item $profile -type file}

接下来可以用记事本打开

& notepad $profile

或 vscode

& code $profile

并将以下内容保存为您的个人资料:

$console = $host.ui.rawui
$console.backgroundcolor = "black"
$console.foregroundcolor = "white"
$colors = $host.privatedata
$colors.verbosebackgroundcolor = "Black"
$colors.verboseforegroundcolor = "Green"
$colors.warningbackgroundcolor = "Red"
$colors.warningforegroundcolor = "white"
$colors.ErrorBackgroundColor = "Yellow"
$colors.ErrorForegroundColor = "Red"
set-location C:\
clear-host