How do I customize text color in IPython?

Colorize and Syntax Style in IPython

First you have to create a ipython profile ~/.iphyton/ipython_config.py in your home directory. ipython_config.py. The easiest way to do so is to run the following command:

ipython profile create

In case you are using ipython3 start

ipython3 profile create

This will install a profile_default directory and some scripts in your ~/.ipython; otherwise find this file on your machine and duplicate it in your ~/.ipython/profile_default/ directory.

Make a backup of this file with:

cp ~/.ipython/profile_default/ipython_config.py{,_backup}

Open the ~/.ipython/profile_default/ipython_config.py with an text editor of your choice and search for following settig 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 are disabled by default; you have only to comment them out (deleting the `#’ ).

Style Files

On Ubuntu/Debian you have to install the pygments package

sudo apt install python3-pygments

or

sudo pip3 install pygments 

The style files can be found in following directory:

/path/to/your/python/site-packages/pygments/styles/, e.g.
/usr/lib/python3/dist-packages/pygments/styles/monokai.py

Alternatively, you can also list your installed styles with pygmentize:

pygmentize -L styles

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)