From 41b2199225fe1e9fc8b83498455d2c83808696fd Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Mon, 1 May 2023 02:19:29 +0200 Subject: [PATCH] add optional Rich highlighting to interactive Python sessions --- lib/python-startup.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/python-startup.py b/lib/python-startup.py index 2e7f018..520f348 100755 --- a/lib/python-startup.py +++ b/lib/python-startup.py @@ -16,7 +16,15 @@ try: except: pass -# bpython gets broken by ANSI colors, so skip those -if type(__builtins__) != dict: - sys.ps1 = '\001\x1b[1;32m\002>>> \001\x1b[0m\002' - sys.ps2 = '\001\x1b[0;32m\002... \001\x1b[0m\002' +try: + import rich + + import rich.traceback + rich.traceback.install() + + import rich.pretty + rich.pretty.install() + + from rich import inspect +except: + pass