MAC中git自动补全配置

git自动补全

  1. 通过Brew安装bash-completion

    brew install bash-completion 安装后通过brew list命令查看安装是否成功

  2. 查看bash-completion安装信息

    brew info bash-comletion

      我的在terminal中展示 添加 [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"至.bash_profile文件中,根据各自输出情况而定

  3. 通过 git --verison命令查看git版本,并用自己机器上的版本号替换网址https://raw.githubusercontent.com/git/git/v2.x.x/contrib/completion/git-completion.bash中的2.x.x,另存为git-completion.bash文件

  4. 拷贝第3步骤中保存的git-completion.bash文件至目录/usr/local/opt/bash-completion/etc/bash_completion.d

  5. 执行命令

    1
    2
    brew unlink bash-completion
    brew link bash-completion