I'm using Zsh. I'd like to have a custom prompt in Python interactive mode. Specifically, I'd like to add color.
If I do in Python something like
sys.ps1 = "\033[38;5;76m>>>\033[0m "
then the prompt displays correctly, but the terminal seems to be confused about the prompt's length, so things get messed up sometimes. This is probably due to the fact that the terminal counts non-printing characters. I need to tell it somehow not to count those characters. But I can't figure out how to do that.
If I use Zsh prompt escapes such as %F{...} or %{ %}, then instead of undergoing expansion, as described here, those escapes are just displayed literally. I guess they don't undergo expansion since the prompt is set from Python rather than in the shell itself.
Zsh counts non-printing characters on default, it doesn't seem to respect [ ] like Bash does, and %{ %} don't undergo expansion when PS1 is set from Python. I'm stuck.
Is there a way to do what I want?