1. 程式人生 > >自定義iTerm2標題欄和bash顯示當前git branch資訊

自定義iTerm2標題欄和bash顯示當前git branch資訊

先來一張效果圖:



怎麼樣?是不是很酷?

下面我來介紹怎麼做到的。

首先

<span style="font-size:24px;">mkdir ~/.bash
cd ~/.bash
git clone https://github.com/jimeh/git-aware-prompt.git</span>

然後編輯~/ .profile或者~/.bash_profile, 兩者都可以。

<span style="font-size:24px;">vi ~/.profile</span>


輸入:
export GITAWAREPROMPT
=~/.bash/git-aware-prompt source $GITAWAREPROMPT/main.sh export PS1="\[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
export PROMPT_COMMAND='echo -ne "\\033]0;${PWD/#$HOME/~}\\007"'
儲存。


執行

<span style="font-size:24px;">source ~/.profile</span>

大功告成!