From d12c0be3429d6116998b7707cf947351980e3c0a Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 23 Oct 2023 15:59:13 +0200 Subject: python: Add Python configuration --- .config/python/startup.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .config/python/startup.py (limited to '.config') diff --git a/.config/python/startup.py b/.config/python/startup.py new file mode 100644 index 0000000..ef80354 --- /dev/null +++ b/.config/python/startup.py @@ -0,0 +1,26 @@ +import atexit +import os +import sys +from pathlib import Path +import readline + + +try: + readline.parse_and_bind("tab: complete") +except ImportError: + pass + + +if hasattr(sys, '__interactivehook__'): + del sys.__interactivehook__ + + +histfile = Path(os.getenv("XDG_CACHE_HOME", Path.home() / ".cache")) / "python_history" +try: + histfile.touch(exist_ok=True) +except FileNotFoundError: + histfile.parent.mkdir(parents=True, exist_ok=True) + +readline.read_history_file(histfile) +readline.set_history_length(5_000) +atexit.register(readline.write_history_file, histfile) -- cgit v1.2.3