AppleMac优雅使用指南寒哥管理的技术专题

mac上使用终端git自动补全

2016-01-03  本文已影响3949人  jarvan4dev

HomeBrew的安装

打开终端,执行以下命令:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

地址可能会有变化,请移步官网查询最新的安装方法
关于brew的使用可参看:http://blog.csdn.net/dracotianlong/article/details/9136017

安装git-completion

命令: brew install git-completion
卸载:brew uninstall <要卸载的插件>
安装过程中会提示你把下面这段配置拷贝到你的 .bash_profile 中:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

没有 .bash_profile就自己见一个咯:

vim ~/.bash_profile
完成拷贝后,保存退出,执行:
source ~/.bash_profile

下载git源码

如果没有事先安置git,则可以使用brew安装:

brew install git

clone git 源码

git clone https://github.com/git/git.git

找到"contrib/completion/"目录下的git-completion.bash,将该文件拷贝到~/下并重命名为.git-completion.bash

source .it-completion.bash

ok, 网上有些说需要新建 ~/.bashrc,然后添加source .it-completion.bash ,好像不是那么需要,我没加。

上一篇下一篇

猜你喜欢

热点阅读