2013-09-01 68 views
7

新手問題,我最近改變了我的PS1到這一點:Bash提示符換行問題

RESET="\[\017\]" 
NORMAL="\[\033[0m\]" 
YELLOW="\[\033[0;33m\]" 
CYAN="\[\033[0;36m\]" 

export PS1="\[$RESET\]\[email protected]\h:\[$CYAN\]\w\[$YELLOW\]\$(__git_ps1)\[$NORMAL\] \$ " 

但現在我得到一個換行錯誤。我創建了一個GIF說明問題:

enter image description here

任何想法可能是錯誤的?

+0

@ __git_ps1'函數做了什麼?你能告訴我們一個代碼嗎? – konsolebox

+0

@konsolebox如果當前目錄是一個git項目,它是一個shell腳本來顯示當前分支。代碼在這裏:https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh – hampusohlsson

+2

+1因爲我喜歡gif –

回答

4

我認爲你用[和]雙引號轉義碼。試試這個:

export PS1="$RESET\[email protected]\h:$CYAN\w$YELLOW\$(__git_ps1)$NORMAL \$ " 
+0

工作就像一個魅力,謝謝! – hampusohlsson