Question

How to make ipdb prompt colored?

It's difficult to navigate between prints:

enter image description here

Was it helpful?

Solution

There doesn’t appear to be an official way to support this, but it can be easily done by editing the source file in your installation. Go to your site packages directory and

grep -r "ipdb>" *

You’ll see something like this:

ipython-2.1.0-py27_2/lib/python2.7/site-packages/IPython/core/debugger.py:42:prompt = 'ipdb> '

Make a backup of that file, then replace the line with what you’d like the prompt to be, including standard color codes. This will make the prompt green, for example:

prompt = '\x1b[32mipdb> \x1b[0m'

There are many places where you can look up more codes for more customization, e.g. http://www.linuxhowtos.org/Tips%20and%20Tricks/ansi_escape_sequences.htm.

Of course, you will have to repeat these steps with any iPython update.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top