照網上的其他人寫的安裝遇到一些問題,最後按下面這個地址中的步驟安裝OK
https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
其他參考:
https://stackoverflow.com/questions/12399002/how-to-configure-git-bash-command-line-completion
https://blog.csdn.net/chenbifeng/article/details/51570606
https://github.com/yszheda/wiki/wiki/git-tips#bash_autocomplete_Unknown_option_listcmdslistmainporcelainothersnohelpersaliaslistcompleteconfig
這裏只記錄下Mac下的,其他系統請直接看上面鏈接。
-
Homebrew 應該都有的的吧
-
brew install git bash-completion .
安裝git 和 bash-completion ,已安裝跳過。
(Install Git and bash-completion: brew install git bash-completion (Note: If this install fails with a 404 error, and you already have git installed, just remove the git part of this brew install)) -
Add bash-completion to your ~/.bash_profile:
將以下語句追加到~/.bash_profile文件中(沒有則創建)
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion || {
# if not found in /usr/local/etc, try the brew --prefix location
[ -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ] && \
. $(brew --prefix)/etc/bash_completion.d/git-completion.bash
}
source ~/.bash_profile
感覺要注意不同系統,不同系統版本(mac的bash版本),不同git版本 ,安裝和配置方式可能都有區別。遇到問題google 、baidu吧,我就遇到按tab 提示的時候出現Unknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config