mac上命令行比windows好用不少,可是git默認按tab鍵是不會自動補全的,很不爽。下面咱們按步驟來介紹怎麼作到自動補全。 git
1.安裝home-brew,相應你們裝裝過了,若是沒裝,直接去官網看下命令行,copy過來裝下就行了。github
2.執行 brew install bash-completion
windows
3.bash
if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi
把上面這段代碼copy到 ~/.bash_profile 中,若是沒有,就建立下這個文件,怎麼建立文件?touch .bash_profile curl
4.打開https://github.com/git/git/bl...,把這個文件下下來,而後url
cp git-completion.bash ~/.git-completion.bash
這個命令意思就是把這個文件拷貝到 ~/目錄下,而且名字前面加了個點。 命令行
5.在~/.bashrc文件(該目錄下若是沒有,新建一個)中添加下邊的內容code
source ~/.git-completion.bash
6.運行get
test -f ~/.git-completion.bash && . $_
而後重啓終端,試試按tab鍵吧。git命令就自動補全了。it
方法二:
一共分兩步,就能夠作到在終端裏用git按tab鍵自動不全命令了:
第一步:
首先下載自動補齊腳本,在終端輸入使用curl命令以下,而後回車,就開始下載了。
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
第二步:
編輯~/.bash_profile 文件,在最後增長以下代碼。若是沒有該文件,就新建一個。
在終端裏輸入:vi ~/.bash_profile
而後粘貼下面的代碼到文件的最後面:
if [ -f ~/.git-completion.bash ]; then source ~/.git-completion.bash fi
重啓終端後應該就能夠愉快的使用tab來自動補全了。