summaryrefslogtreecommitdiff
path: root/.config/python/pythonrc
diff options
context:
space:
mode:
Diffstat (limited to '.config/python/pythonrc')
-rw-r--r--.config/python/pythonrc22
1 files changed, 22 insertions, 0 deletions
diff --git a/.config/python/pythonrc b/.config/python/pythonrc
new file mode 100644
index 0000000..9ab457e
--- /dev/null
+++ b/.config/python/pythonrc
@@ -0,0 +1,22 @@
+import os
+import atexit
+import readline
+
+state_home = os.environ.get("XDG_STATE_HOME")
+if state_home is None:
+ state_home = os.path.join(os.path.expanduser('~'), ".local", "state")
+
+history = os.path.join(state_home, "python_history")
+
+try:
+ readline.read_history_file(history)
+except OSError:
+ pass
+
+def write_history():
+ try:
+ readline.write_history_file(history)
+ except OSError:
+ pass
+
+atexit.register(write_history)