目录
下载 Git 的源代码
在目录中 git/contrib/completion/ 中找到 git-completion.bash 文件
将 git-completion.bash 文件改名为 .git-completion.bash
找到本机git安装目录
将.git-completion.bash文件复制到git安装目录下的etc文件夹
打开同目录下的 bash.bashrc 文件,在文件末尾添加:
测试效果:
下载 Git 的源代码
git clone https://github.com/git/git.git
在目录中 git/contrib/completion/ 中找到 git-completion.bash 文件
或者直接下载git-completion.bash文件:
Github (Git官方):
git/git-completion.bash at master · git/git · GitHubGit Source Code Mirror - This is a publish-only repository but pull requests can be turned into patches to the mailing list via GitGitGadget (https://gitgitgadget.github.io/). Please follow Documentation/SubmittingPatches procedure for any of your improvements. - git/git-completion.bash at master · git/githttps://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Gitee (复制):
https://gitee.com/JackieZheng/git/blob/master/contrib/completion/git-completion.bashhttps://gitee.com/JackieZheng/git/blob/master/contrib/completion/git-completion.bash
将 git-completion.bash 文件改名为 .git-completion.bash
原文件名前加“.”即可
找到本机git安装目录
where git
将.git-completion.bash文件复制到git安装目录下的etc文件夹
打开同目录下的 bash.bashrc 文件,在文件末尾添加:
source ~/.git-completion.bash
测试效果:
输入git命令,按Tab键,如果有多个相似命令会输出所有相似命令,如果命令唯一会直接补全