How to change iPython error highlighting color

Viewed 553

I'm using iPython with iterm2 in macOS. I had never had issues before with the color scheme, but this time when an exception occurs, it highlights certain parts in a color combination that I find very hard to read. I've tried with different color setups in iterm and also adjusting highlighting_style and colors in the ipython_config.py file, without much luck. I've seen there is an option to set specific colors highlighting_style_overrides but I haven't been lucky finding the right pygments option for this.

See Position below. This is the best contrast setup I've achieved, I still find hard it to read without focusing.

enter image description here

1 Answers

There is an open issue regarding this: https://github.com/ipython/ipython/issues/13446


Here is the commit which introduced this change:

https://github.com/ipython/ipython/commit/3026c205487897f6874b2ff580fe0be33e36e033

To get the file path on your system, run the following:

import IPython, os
os.path.join(os.path.dirname(IPython.__file__), 'core/ultratb.py')

Finally, open the file and look for:

style = stack_data.style_with_executing_node(style, "bg:ansiyellow")

For the time being, you can manually patch it by changing bg:ansiyellow to something that works best given your color scheme, e.g. bg:ansired or bg:#ff0000.

Related