2012-07-10 55 views
1

我剛剛完成定製的OS X.總之我的bash命令提示符,它現在可以讓我開始新生產線鍵入命令:Ctrl + A快捷的工作incorrecly Bash中

alexey::machine { ~/rails/jutge } (git: static-pages) 12:55 PM 
-> bundle exec rspec spec/requests/static_pages_spec.rb 

當我決定使用Ctrl + A快捷鍵移動到行的起始位置,我轉到第4個字符,並刪除它之前的所有三個(我用'$'符號標記光標位置):

-> bun$dle exec rspec spec/requests/static_pages_spec.rb 

我的意思是,前三個字符仍然顯示,但不可訪問和不可編輯。

我將不勝感激關於如何解決它的任何指示。謝謝。

我的.bash_profile和.bashrc中的內容:

function parse_git_branch() { 
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 
} 

PS1="\e[1;33m\u::\h\e[m \e[0;32m{ \w }\e[m\e[0;36m\$(parse_git_branch)\e[m\e[1;34m\@\e[m\e[1;35m\n->\e[m " 
+0

如果您發佈了'.bashrc'(或等價物)的內容,這隻能回答滿意。 – 2012-07-10 11:48:10

+0

@rody_o將它添加到quiestion – appplemac 2012-07-10 12:12:18

回答

5

你需要附上PS1的非打印字符\ [... \],這樣的bash能夠正確計算提示的大小。

PS1="\[\e[1;33m\]\u::\h\[\e[m\] \[\e[0;32m\]{ \w }\[\e[m\e[0;36m\]\$(parse_git_branch)\[\e[m\e[1;34m\]\@\[\e[m\e[1;35m\]\n->\[\e[m\] " 
+0

你打敗了我。 :) – 2012-07-10 12:48:56

+0

謝謝!現在它完美地工作。 – appplemac 2012-07-10 12:54:27

相關問題