如何在获取冒号后删除自动完成文本?

Jul*_*ipe 3 git

如何删除fetch自动完成功能,但只能在 git 上的冒号 (:) 之后?

我的意思是,在我输入之后

$ git fetch origin m<tab>

,它自动完成

$ git fetch origin master:master

,我想自动完成

$ git fetch origin master

, 没有“冒号部分”(就像以前版本的 git)。

大多数时候我已经在 master 或任何分支上,我不想像这样将远程分支合并到我的本地分支中。

谢谢!

Jul*_*ipe 5

感谢clmno指出这一点。

/usr/share/bash-completion/completions/git__git_complete_remote_or_refspec ()函数中编辑了文件,注释了以下几行:

case "$cmd" in
  fetch)
    #if [ $lhs = 1 ]; then
    #  __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
    #else
      __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" # leave this uncommented
    #fi
    ;;
Run Code Online (Sandbox Code Playgroud)

和它的作品,因为我想要的期望。