我刚刚完成了在OS X中自定义我的Bash命令提示符。简而言之,它现在允许我从新行开始键入命令:
alexey::machine { ~/rails/jutge } (git: static-pages) 12:55 PM
-> bundle exec rspec spec/requests/static_pages_spec.rb当我决定使用Ctrl +A快捷键移动到行的开头时,我转到第4个字符,之前的3个字符都被删除了(我用'$‘符号标记了光标位置):
-> 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 "发布于 2012-07-10 20:45:32
您需要将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\] "https://stackoverflow.com/questions/11411941
复制相似问题