summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-10-23 15:59:13 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-10-23 15:59:13 +0200
commitd12c0be3429d6116998b7707cf947351980e3c0a (patch)
tree25e189d476b2eb29def98e79b055efd6603ac085 /.config
parentd1de575a36831ee876ad75adefd983d232dd69d1 (diff)
python: Add Python configuration
Diffstat (limited to '.config')
-rw-r--r--.config/python/startup.py26
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)