Sunday, August 23, 2020

Configuring Custom ipython Terminal Color Scheme

In some cases ipython default terminal color scheme is not the most readable one, especially when using Powershell in Windows. One of the way to fix the problem is to use custom/non-default color scheme. The steps to accomplish that as follows (tested in ipython v7.17 and python 3.7.9):

  1.  Run `pygmentize -L styles` in your terminal to check available ipython color styles/schemes. Experiment with the color scheme by starting ipython while settting the color scheme as one of its starting parameter, for example: ipython TerminalInteractiveShell.highlighting_style=native. Replace native with the color scheme that you want to test. ipython should start with the color scheme that you specify.
  2. Create default ipython configuration file for the current user by running: `ipython profile create` , just use the default configuration file. See: https://ipython.readthedocs.io/en/stable/config/intro.html for more in depth explanation of this command. 
  3. Edit the default configuration file located at: ~/.ipython/profile_default/ipython_config.py. In Windows, this file is located at: C:\Users\[username]\.ipython\profile_default\ipython_config.py.  Open the ipython_config.py file and edit the line that contain c.TerminalInteractiveShell.highlighting_style parameter. Set this config value to the color scheme that you want to make permanent. For example, in my config, I set the value to 'native' as follows: c.TerminalInteractiveShell.highlighting_style = 'native'. This will apply the 'native' color scheme as the default color scheme when you start ipython. 
The result of this configuration changes in my Powershell is shown below.



Post a Comment

No comments: