Skip to content
Advertisement

How do I customize text color in IPython?

I’d like to customize the color of text in IPython, but am not sure how to do it.

I know that in Python, I can do this by ending sys.ps1 and sys.ps2 with an ANSI color code such as

JavaScript

But the corresponding approach, using PromptManager.in_template, does not work for IPython. For example

JavaScript

has no effect on the color of text after the prompt.

Is there a way to change the color of text in IPython?

Advertisement

Answer

The prompt explicitly sets the color of input to colors.in_normal. If you want to change the input color, you have to change this color.

Unfortunately, customized color schemes are still on the todo list (should be pretty easy, just not a high priority).

A somewhat hackish example of what you seem to want, changing the color of input and/or output text in a config file:

JavaScript

This will set it so that the color of text matches the prompt, but you can of course choose whatever you want.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement