Windows 10 Pro 1903 更新中与 ripgrep / less 的奇怪交互(白色控制台)

Windows 10 Pro 1903 更新中与 ripgrep / less 的奇怪交互(白色控制台)

我的操作系统最近升级到了 Windows 10 Pro 1903,但less.exe在某些情况下我的版本停止了正常工作;它在命令提示符中显示白底白字的行为。

这似乎发生在我运行之后ripgrep;在我运行之前ripgrepless工作正常,但是在运行 ripgrep 之后,命令提示符颜色设置中发生了一些变化,我得到了白底白色的行为。

在更新之前的 Windows 10 版本中,并没有出现这种情况。

C:\>less --version
less 340
Copyright (C) 1999 Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of less under the terms
of the GNU General Public License.
For more information about these matters,
see the file named COPYING in the less distribution.

C:\>rg --version
ripgrep 0.10.0 (rev 8a7db1a918)
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

有人能帮我找出如何修复或解决方法吗?

答案1

唔。color修复颜色,至少直到我下次运行 ripgrep。

https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#stop-ripgrep

当我杀死 ripgrep 时,如何阻止它弄乱颜色?在 cmd.exe(命令提示符)中输入 color,在类 Unix 系统上输入 echo -ne "\033[0m" 以恢复原始前景色。

在 PowerShell 中,您可以将以下代码添加到配置文件中,当调用 Reset-ForegroundColor 时,它将恢复原始前景色。包括 Set-Alias 行将允许您使用简单的颜色来调用它。

function Reset-ForegroundColor {
    $Host.UI.RawUI.ForegroundColor = $OrigFgColor
}
Set-Alias -Name color -Value Reset-ForegroundColor

PR #187 修复了这个问题,后来在 #281 中弃用了它。完整解释如下这里

相关内容