别名的 Git 补全仅在运行“git reflog”后可用

别名的 Git 补全仅在运行“git reflog”后可用

我有一些想要为 git 自动完成的别名,例如以下

alias gco="git checkout"

当我尝试为此别名添加补全时,我环顾路径,发现有一堆可用的 git 补全(例如,_git-push, _git-checkout, _git-diff-files)。我曾经compdef这样定义它:

compdef _git-checkout gco

这工作了一段时间,然后我重新启动了我的终端,突然它们都消失了......(收到有关完成不可用的错误):

gco (eval):1: command not found: _git-checkout
(eval):1: command not found: _git-checkout
(eval):1: command not found: _git-checkout

奇怪的是,在我跑步后,它们都被扔到了我的路上git reflog。 (然后他们就工作了)。我是否在这里依赖了一些不应该依赖的内部函数?我应该以不同的方式处理这个问题吗? (我也可以git reflog在我的 中添加 a .zshrc,但这似乎完全荒谬)。

相关内容