在 Windows 终端内使用 git-posh 或/和 oh-my-posh 以及命令提示符(cmd,而不是 Powershell)
最近切换到新 Windows 终端 ,经过几个小时的互联网搜索后,我找不到任何有用的东西,我想要的就是在新的 Windows 终端中设置 cmd 以显示 git 分支,就像 powershell 可以实现的那样。
我对 cmd 非常满意,尤其是它能够使用其他 Linux 命令,并且不想仅仅因为 git 分支的良好显示而切换到 powershell。 this 是一个源代码,其中对 powershell 的所有内容都进行了很好的解释,我想要的就是对 CMD 执行相同的操作。
提前致谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使用Oh My Posh进行 shell 提示自定义<强>来自
cmd.exe
,旧版Windows shell(引用自docs,选项卡cmd
,添加强调):正如您后来发现的那样,GitHub 上的此问题提供了有关原因的背景信息本机
cmd.exe
支持是不可能的(尽管 Oh My Posh 通常与 shell 无关),以及为什么需要第三方软件才能使其工作。至于您更喜欢
cmd.exe
的评论:从一个已经习惯的 shell 迁移到一个新的 shell 无疑是一个痛苦的过渡,但在这种情况下非常值得考虑:
虽然并非没有怪癖,但 PowerShell 在几乎所有方面都远远优于
cmd.exe
,使您能够执行cmd.exe
中无法执行的操作从 Windows 端调用的 Linux (WSL) 命令都是通过可执行文件(特别是
wsl.exe
和bash.exe),您同样可以从 PowerShell 中调用它。
In order to use Oh My Posh for shell-prompt customization from
cmd.exe
, the legacy Windows shell (citing from the docs, tabcmd
, emphasis added):As you later discovered, this issue on GitHub has background information on why native
cmd.exe
support isn't possible (even though Oh My Posh is generally shell-agnostic) and why third-party software is needed to make it work.As for your comments re preferring
cmd.exe
:Migrating from the shell one is used to a new one is undoubtedly a painful transition, but well worth considering in this case:
While not without its quirks, PowerShell is vastly superior in just about every respect to
cmd.exe
, and enables you to do things you simply cannot do incmd.exe
Linux (WSL) commands called from the Windows side are all mediated via executables (notably
wsl.exe
andbash.exe
), which you can equally call from PowerShell.