diff options
Diffstat (limited to '.config/python')
-rw-r--r-- | .config/python/startup.py | 26 |
1 files changed, 26 insertions, 0 deletions
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) |