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
sys.ps1=">>> \001\033[0m\033[34m\002"
But the corresponding approach, using PromptManager.in_template
, does not work for IPython. For example
c = get_config()
c.PromptManager.in_template = 'In [{count}] : {color.Blue}'
has no effect on the color of text after the prompt.
Is there a way to change the color of text in IPython?
Looking in your installation directory you will find a file called ipython_config.py. To install this file simply use the following command:
ipython profile create
Otherwise find this file and copy it in your ~/.ipython/profile_default/ directory.
Maybe you like to make a backup of this file with:
cp ~/.ipython/profile_default/ipython_config.py \
~/.ipython/profile_default/ipython_config.py_backup
Open this file with your editor of choice and search for following settigs and comment it out if you like it (delete the '#'):
c.InteractiveShell.color_info = True
c.InteractiveShell.colors = 'Linux'
c.TerminalInteractiveShell.highlighting_style = 'monokai'
c.TerminalInteractiveShell.highlight_matching_brackets = True
and so on. There are many usefull settings which you have only to comment them out (deleting the #)
Style Files
The style files can be found in following directory:
/path/to/your/python/site-packages/pygments/styles/
Alternatively, list the styles with pygmentize
: pygmentize -L styles