Sna*_*hot 25 powershell colors node.js
我开始使用PowerShell用于使用node.js的Windows项目.从Powershell命令行运行许多程序(包括node,supervisor和npm)时,我的PowerShell背景和前景颜色开始从默认的Powershell颜色更改.如何在PowerShell中保持一致的外观,以便我可以轻松读取运行命令的结果?
Sha*_*tin 62
作为一次性操作,只需执行以下操作:
> [Console]::ResetColor()
Run Code Online (Sandbox Code Playgroud)
来自文档:( 重点补充)
前景色和背景色将恢复为当前流程开始时存在的颜色.
Kei*_*ill 17
我有这个问题与MSBuild特别是当我ctrl + C一个构建.这是我放在profile.ps1文件中的内容:
$OrigBgColor = $host.ui.rawui.BackgroundColor
$OrigFgColor = $host.ui.rawui.ForegroundColor
# MSBUILD has a nasty habit of leaving the foreground color red
# if you Ctrl+C while it is outputting errors.
function Reset-Colors {
$host.ui.rawui.BackgroundColor = $OrigBgColor
$host.ui.rawui.ForegroundColor = $OrigFgColor
}
Run Code Online (Sandbox Code Playgroud)
然后我只是在MSBuild弄乱它们时调用Reset-Colors.
Sna*_*hot 13
首先在PowerShell中创建一个配置文件,如果您还没有配置文件:
test-path $profile
new-item -path $profile -itemtype file -force
notepad $profile
Run Code Online (Sandbox Code Playgroud)
其次,将此代码放在文件中:
function prompt {
[Console]::ResetColor()
}
Run Code Online (Sandbox Code Playgroud)
第三,检查PowerShell是否允许您运行脚本.
Get-ExecutionPolicy
Run Code Online (Sandbox Code Playgroud)
如果这表示受限制,则运行以下AS管理员(请确保您了解安全隐患):
Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
打开一个新的PowerShell提示符,您应该能够运行节点或其他命令而不会出现任何颜色问题.
归档时间: |
|
查看次数: |
9619 次 |
最近记录: |