我可以通过 cmd.exe 在 Windows 上为 git 设置自动完成功能吗?
我最近了解到,在 Linux 上,git 可以设置为自动完成命令:如果您输入
git br
那么它会将其完成到 gitbranch。
Windows 上可以设置同样的自动完成功能吗?
更新 - 我通常通过 cmd.exe 使用 git (我将 git 添加到我的路径中)。这个问题是关于在 cmd 上向 git 添加自动完成功能(如果可能的话)。
I've recently learned that on linux, git can be setup to autocomplete commands: If you type
git br<TAB>
Then it will complete it to git branch
.
Can the same auto-completion be set up on Windows?
Update - I'm usually working with git via cmd.exe (I added git to my path). This question is about adding auto-completion to git on cmd, if that's possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
安装 Clink 似乎让这项工作变得神奇,并在 cmd、Console2 和 ConEmu 中进行了验证。
http://mridgers.github.io/clink/
更新:让 ConEmu 和 clink 正常工作对于较新的版本,需要将 clink 安装到 ConEmu 文件夹中。请参阅 https://github.com/mridgers/clink/issues/339 和 https://github.com/Maximus5/ConEmu/issues/270 了解更多信息。
Installing Clink seems to make this work by magic, verified in cmd, Console2, and ConEmu.
http://mridgers.github.io/clink/
UPDATE: To get ConEmu and clink to work properly with the more recent versions, it was necessary to install clink into the ConEmu folder. See https://github.com/mridgers/clink/issues/339 and https://github.com/Maximus5/ConEmu/issues/270 for more info.
对于未来的读者,我发现 posh-git 与 Windows 终端 是一种美妙的 git 体验。
这是
powershell
,而不是cmd.exe
。For future readers, I have found that posh-git combined with Windows Terminal is a beautiful git experience.
This is
powershell
, notcmd.exe
though.您必须使用某种形式的 bash 才能使其工作,无论是 msysgit 附带的 git bash 还是其他 bash(您需要对其进行设置以使用 git bash 中使用的自动完成功能)。使用 cmd.exe 你不会有好运。
将此视为您抛弃旧的生锈的 cmd.exe 的标志。输入bash之光! :)
You have to use some form of bash to get it to work, either git bash that comes with msysgit or some other bash (which you need to setup to use the autocompletion used in git bash). With cmd.exe you will have no luck.
Look at this as a sign for you to leave old rusty cmd.exe behind. Enter the light of bash! : )
clink 和强大的补全
clink 和分支完成
如果上述方法太复杂,您可以使用“轻量级”完成。
%APPDATA%\..\Local\clink
(将其粘贴到 Windows 资源管理器的地址栏中)git-autocomplete.lua
移动到该文件夹。cmd.exe
。请注意,这不适用于上面的 git.lua,因为该 lua 文件也需要其他 lua 文件。请参阅 https://github.com/vladimir-kotikov/clink-completions/issues /166了解详情。
clink and powerful completions
clink and branch completions
In case the above method is too complicated, you can have "lightweight" completion.
%APPDATA%\..\Local\clink
(paste that in the address bar of Windows Explorer)git-autocomplete.lua
to that folder.cmd.exe
.Note that this does not work for the above
git.lua
, because that lua file needs other lua files, too. See https://github.com/vladimir-kotikov/clink-completions/issues/166 for details.安装 Clink 似乎让这项工作变得神奇,这里有一个仍在维护的分支: https://github.com /chrisant996/clink
原始存储库似乎已被放弃。
Installing Clink seems to make this work by magic, here is a fork that's still being maintained: https://github.com/chrisant996/clink
The original repo seems to have been abandoned.
最近,我刚刚发现 git 自动完成功能在传统的 cmd.exe 上不起作用,但如果我启用 Windows sub-Linux 功能,它确实可以工作,在 Windows bash 命令行上工作得很好
Recently, I just found the git auto-completion is not working on the traditional cmd.exe but did works if I enable the Windows sub-Linux feature, working pretty well on the Windows bash command line