【问题标题】:Mercurial color extension in Windows PowershellWindows Powershell 中的 Mercurial 颜色扩展
【发布时间】:2010-10-21 03:08:04
【问题描述】:

有没有办法在 Windows 7 上的 Powershell 中启用对 Mercurial 的颜色支持? ColorExtension 页面说要添加

[color]
mode = win32

到您的.hgrc 文件,但似乎没有什么不同。

运行hg status 显示了几个尚未添加到存储库中的文件,我相信它们应该是粉红色的(基于我见过的其他终端)。这是显示的内容:

←[0;35;1;4m? samplefile.php←[0m
←[0;35;1;4m? anotherfile.php←[0m
←[0;35;1;4m? derpderp.xml←[0m
←[0;35;1;4m? derp_model.php←[0m
←[0;35;1;4m? stillnocolor.php←[0m

【问题讨论】:

    标签: windows powershell mercurial dvcs


    【解决方案1】:

    您可能需要更新到最新的 mercurial (1.6.4)。尤其是 1.5.4 版没有正确处理 win32 颜色(并且在最近的版本中修复了很多与颜色相关和与 win32 相关的错误)。

    您还需要确保您没有指定 ANSI 颜色模式。你可以强制win32:

    [color]
    mode = win32
    

    【讨论】:

    • 很好,我没有意识到我运行的是旧版本。
    • 在 Mercurial 2.8 中不起作用。有关更多信息,请参阅我的答案。
    【解决方案2】:

    您是否还确保启用了 ColorExtension?你的 .hgrc 中也需要这个:

    [extensions]
    color =
    

    如果那里也有,您可以确保您的设置被拾取:

    hg --debug showconfig
    

    【讨论】:

    • 是的,扩展已启用。设置显示得很好,所以我不确定它们为什么不显示。
    【解决方案3】:

    ColorExtension 在 PowerShell 2.8 版本中无法使用,请参阅https://www.mercurial-scm.org/pipermail/mercurial-devel/2013-November/054620.html

    当使用 Windows PowerShell 颜色不起作用时(尽管它与 cmd.exe 完美匹配)。

    看起来虽然被调用,_kernel32.SetConsoleTextAttribute 在 PowerShell 中运行时没有任何效果。

    这是Mercurial bug 4093,已解决为“无法修复”。一种解决方法是使用ansicon。有关更多信息,请参阅this 答案。

    【讨论】:

    猜你喜欢
    • 2012-07-17
    • 2013-09-25
    • 2021-06-12
    • 1970-01-01
    • 2014-06-01
    • 2011-02-03
    • 1970-01-01
    • 2011-07-25
    • 2015-01-25
    相关资源
    最近更新 更多