Adding colors to python interpreter tooltip, not wrapping properly

I would like to have a more colorful Python hint in the terminal, just for readability. I currently have:

sys.ps1 = '\033[96m>>> \033[0m' sys.ps2 = '\033[96m... \033[0m' 

in my PYTHONSTARTUP file, which gives it colors as desired. However, any text above the line does not wrap properly. The text goes to the end of the line, and instead of immediately starting a new line, it starts overwriting the beginning of the first line before starting a new line. As you can imagine, this is actually pretty impenetrable. How can I fix this behavior?

+7
source share
2 answers

Try the following:

 sys.ps1 = '\001\033[96m\002>>> \001\033[0m\002' sys.ps2 = '\001\033[96m\002... \001\033[0m\002' 

This answer to a similar question explains why \001 and \002 are needed.

+10
source

Is there any reason not to use IPython ? IPython provides color hints, etc. From the box...

+2
source

Source: https://habr.com/ru/post/917652/


All Articles