Configure iPython with Rich for Pretty REPL Formatting

May 23, 2022

When using the iPython repl, you can configure rich to be autoloaded when the repl is started. Gives you clean formatting out of the box.

Create ipython profile:

ipython profile create <profilename>

Add relevant settings:

# ~/.ipython/profile_default/ipython_config.py
 
c.InteractiveShellApp.extensions = [
    'rich'
]
 
c.InteractiveShellApp.exec_lines = [
    "from rich import inspect",
    "from rich import traceback",
    "traceback.install(show_locals=False, extra_lines=1, max_frames=3)",
    "from rich import pretty",
    "pretty.install()",
]