为什么 debian 不能自动完成所有 git 命令?

为什么 debian 不能自动完成所有 git 命令?

我正在运行 Debian

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

我安装了 git,并尝试获取 git 自动完成功能。很久以前读过一篇文章,我注意到我需要安装 bash-completion。

我这样做了,并且执行了很多自动完成命令:

sudo apt-get install git bash-completion

但是,仍有一些 git 命令无法自动完成。例如:

git stash list --name-only (Does not autocomplete --name-only)

这是为什么?我能以某种方式修复它吗?

答案1

上次我检查时,bash-completion软件包中包含的 Git 自动完成功能提供的功能比 Git 本身附带的功能少。

我建议下载最新的版本,并提供以下来源:

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

然后添加到您的~/.bash_profile

[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash

更多信息请访问Git 网站

相关内容