ZSH RPROMPT weird spacing?

倖福魔咒の 提交于 2019-12-03 00:07:56

I believe $fg[color] contains something like \e[32m? If so, it must be enclosed in %{…%} to indicate that this sequence has no width. But much better if you forget about the whole thing and use %F{color} for foreground, %K{color} for background and %f/%k to cancel them in place of $reset_color. You must do

setopt promptsubst
setopt promptpercent

in order for this to work (you likely already do have this).

That gap is the width of colors, and they are the reason why you have wrong cursor position. Problem here is that zsh can’t query terminal with the question “Hey, I outputted some text, what is its width?” instead having to calculate width on its own.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!