mac上使用终端git自动补全

作者: jarvan4dev | 来源:发表于2016-01-03 00:50 被阅读3949次

    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 ,好像不是那么需要,我没加。

    相关文章

      网友评论

      • Mr_Dragonn:找到"contrib/completion/"目录下的git-completion.bash,将该文件拷贝到~/下并重命名为.git-completion.bash
        提示重命名不能以.开头怎么办
        jarvan4dev: @Mr_Dragonn 使用mv命令啊
      • webCoder:brew install bash-completion
        webCoder:@Eason4dev 你写的 install git-completion
        jarvan4dev:@webCoder 啥?

      本文标题:mac上使用终端git自动补全

      本文链接:https://www.haomeiwen.com/subject/mcvghttx.html