You are overcomplicating this; you appear not to be closing any of the %{
to properly mark an ANSI escape sequence as a zero-width item for purposes of calculating the prompt length and cursor position, but you don't need raw ANSI escape sequences in the first place.
This does require you to represent your RGB triplets in hexadecimal first, though.
PROMPT='%B%F{#e06c75}(' # 224 == 0xe0, 108 == 0x6c, 117 == 0x75
PROMPT+='%F{...}%n'
PROMPT+='%F{...}%(#.??.@)'
PROMPT+='%F{...}%m'
PROMPT+='%F{...})-['
PROMPT+='%F{...}%~'
PROMPT+='%F{...}]'
PROMPT+='%F{...}$:'
PROMPT+='%b%f'
The benefit of using %F
is that zsh
already knows that the byte sequence it produces should not contribute to the prompt length, relieving you of the burden of using %{ ... %}
everywhere.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…