2014/10/11

讓 Git 使用起來更方便的一些 tips


(Full Moon.Taipei)

第一件事是讓 terminal 可以支援 git command 還有 branch name 的自動補齊,不用每次都要記落落長的分支名稱。

1. 下載 autocomplete 的 shell script

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
 
2. 在 ~/.bash_profile 中加入下面的 script

if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi 
 
然後重新載入一下 .bash_profile 就可以了。
   
第二件事是讓 terminal 的 prompt 可以顯示目前是在哪個分支。
方法也很簡單,在 PS1 這個變數中,適當的位置加入 \$(__git_ps1) 就可以了。
像我的設法是:
 
export PS1='\[\e[36;1m\][\h]\[\e[33;1m\]\t \[\e[0m\]\[\e[32;1m\]\w \[\e[0m\]$(__git_ps1 "(%s)")\n$'
 
REF: 
1. http://code-worrier.com/blog/autocomplete-git/
2. http://code-worrier.com/blog/git-branch-in-bash-prompt/
 
 
 
 

沒有留言:

張貼留言

中國 App 商業模式 -- 王泌

很有系統地介紹了中國近幾年比較大的幾十個 app,包含他們主要的商業模式,投資者,和特色在哪裡。對於想要了解中國 App (網路服務) 市場的人來說,會是個很好的入門書。雖然已經是兩三年前的資料了,這兩三年又有了很大的變化,但依然是個很好的起點。