git 添加tab补全

  1. 从github获取 git-completion.bash
  2. git-completion.bash放在/etc/bash_completion.d/ 目录中 cp ./git-completion.bash /etc/bash_completion.d/git-completion.bash
  3. ~/.bashrc中添加如下代码
    if [ -f /etc/bash_completion.d/git-completion.bash ]; then
        . /etc/bash_completion.d/git-completion.bash
    fi
    
  4. 执行source ~/.bashrc使其生效
  5. ~/.bashrc的执行依赖于~/.bash_profile如果~/.bash_profile不存在则创建该文件并添加如下代码
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi
    
原文地址:https://www.cnblogs.com/junly/p/6908012.html