- 从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