How to make ipdb prompt colored?

It's difficult to navigate between prints:

enter image description here

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top