[英]Showing git branch in ConEMU
有没有办法在 ConEmu 中以视觉方式(背景或类似)显示 git 中的分支?
Git branch can be visible in plain cmd or Far Manager prompt. Git 分支可以在普通的 cmd 或 Far Manager 提示符下可见。
All magic is done with special ANSI sequences ("Inject ConEmuHk" and "ANSI X3.64 ..." options must be checked).所有魔法都是用特殊的 ANSI 序列完成的(必须选中“Inject ConEmuHk”和“ANSI X3.64 ...”选项)。 I Run GitShowBranch /i
to install showing branch, GitShowBranch /u
to uninstall.我运行GitShowBranch /i
来安装显示分支,运行GitShowBranch /u
来卸载。
Also, you may run your cmd as following (within Task contents or ConEmu's Command line)此外,您可以按如下方式运行您的 cmd(在任务内容或 ConEmu 的命令行中)
cmd /k ver & GitShowBranch /i
PS.附注。 File GitShowBranch
exists in ConEmu's distro, but you may see it online .文件GitShowBranch
存在于 ConEmu 的发行版中,但您可能会在网上看到它。
Change the specified named task
to {Bash::Git}
in Settings -> Startup and you'll have branch name showing up.在 Settings -> Startup 中将specified named task
更改为{Bash::Git}
,您将看到分支名称。
Yes there is a way.是的,有办法。 Install git bash , then in ConEmu settings, under the "ComSpec" section set the Explicit executable to "C:\\Program Files (x86)\\Git\\bin\\sh.exe" --login -i
.安装git bash ,然后在 ConEmu 设置中,在“ComSpec”部分下将显式可执行文件设置为"C:\\Program Files (x86)\\Git\\bin\\sh.exe" --login -i
。
This runs a bash shell session, and gives you a fully resizable window, with the git tab completion and current working branch prompt.这将运行一个 bash shell 会话,并为您提供一个完全可调整大小的窗口,带有 git tab 完成和当前工作分支提示。
Disclaimer #1免责声明#1
ConEmu is not a shell, so it does not provide "shell features" like tab-completion, command history and others. ConEmu 不是 shell,因此它不提供“shell 功能”,例如制表符完成、命令历史记录等。
Usually, Git information like branch or amount of changes is displayed in the command line prompt, for example C:\\path\\to\\repository [branch|+2~4-6]>
.通常,命令行提示符中会显示分支或更改量等 Git 信息,例如C:\\path\\to\\repository [branch|+2~4-6]>
。 This is done by the executing shell, not the console frame.这是由正在执行的 shell 完成的,而不是控制台框架。
As far as I know, the standard Windows command prompt (CMD) does not support modifying that.据我所知,标准的 Windows 命令提示符 (CMD) 不支持修改它。 The bash that comes with Git for Windows already supports that perfectly though;不过, Git for Windows附带的 bash 已经完美地支持了这一点; and for PowerShell there are numerous extensions for Git, most notably posh-git .对于 PowerShell,有许多 Git 扩展,最著名的是posh-git 。
To sum up the situation is:总结一下情况是:
I know sh.exe
can do this but needed to check if it is in the Git\\bin
folder and have access by only writing sh
in command line.我知道sh.exe
可以做到这一点,但需要检查它是否在Git\\bin
文件夹中,并且只需在命令行中写入sh
访问。
First I saw sh.exe
in Git\\bin
folder but wanted to see if I can execute on command line.首先我在Git\\bin
文件夹中看到了sh.exe
,但想看看我是否可以在命令行上执行。 To see it I checked environment vars using by echo %path%
It was complicated to see if there is.为了查看它,我使用了echo %path%
检查了环境变量。查看是否存在很复杂。 I used powershell script and there is :)我使用了 powershell 脚本,并且有 :)
I would have execute sh in command line too :)))我也会在命令行中执行 sh :)))
Refrences:参考资料:
Codes:代码:
echo %path%
($env:Path).split(";") | where ({$_ -like "*Git*"})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.