- 从github获取 git-completion.bash
- 将
git-completion.bash
放在/etc/bash_completion.d/
目录中cp ./git-completion.bash /etc/bash_completion.d/git-completion.bash
- 在
~/.bashrc
中添加如下代码if [ -f /etc/bash_completion.d/git-completion.bash ]; then . /etc/bash_completion.d/git-completion.bash fi
- 执行
source ~/.bashrc
使其生效 ~/.bashrc
的执行依赖于~/.bash_profile
如果~/.bash_profile
不存在则创建该文件并添加如下代码if [ -f ~/.bashrc ]; then . ~/.bashrc fi