From 1654c2ebf6ce4612890291dc362ba8aa6a9caae0 Mon Sep 17 00:00:00 2001 From: Trysdyn Black Date: Fri, 5 May 2023 15:24:55 -0700 Subject: [PATCH] Add python REPL configs - Rich for prettification - Don't write a python_history --- .config/pythonrc | 21 +++++++++++++++++++++ .profile | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 .config/pythonrc diff --git a/.config/pythonrc b/.config/pythonrc new file mode 100644 index 0000000..03249dd --- /dev/null +++ b/.config/pythonrc @@ -0,0 +1,21 @@ +try: + import readline +except ImportError: + print("Module readline not available.") +else: + # Add tab completion + import rlcompleter + readline.parse_and_bind("tab: complete") + + # Don't write history on exit + readline.write_history_file = lambda *args: None + + +# Try to install rich's prettification stuff +try: + from rich import pretty +except ImportError: + print("Failed to import Rich for CLI prettification") +else: + pretty.install() + diff --git a/.profile b/.profile index 12e2969..6613d30 100644 --- a/.profile +++ b/.profile @@ -22,3 +22,6 @@ fi export HISTFILE=~/.history export HISTSIZE=10000 export SAVEHIST=10000 + +# Use my special pythonrc to customize my REPL +export PYTHONSTARTUP=~/.config/pythonrc