Created
November 30, 2012 07:53
-
-
Save kejyun/4174397 to your computer and use it in GitHub Desktop.
git prompt命令列特殊顏色及分支顯示設定
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 取得git branch名稱 | |
function git_branch { | |
# 取得git branch,若此資料夾沒有git brangh,則將錯誤訊息丟至回收桶,回傳空值 | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
# 若有取得git branch,則將取得的名稱「ref/heads/branchname」,並將前面的前贅詞去除,只保留branch名稱 | |
echo "("${ref#refs/heads/}") "; | |
} | |
# 設定prompt名稱為 [資料夾路徑 現在時間] (branch) | |
# \e[1;32m:綠色 | |
# \e[1;35m:紫色 | |
# \e[1;36m:青色 | |
PS1="[\[\e[1;32m\]\w\[\e[0m\] \[\e[1;35m\]\t\[\e[0m\]] \[\e[1;36m\]\$(git_branch)\[\e[0m\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment