1
0
Fork 0

add `python` config

main
urosm 2024-01-27 21:13:12 +01:00
parent 25676d07e4
commit 04c4f8d70c
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
import os
import atexit
import readline
if "PYTHONHISTFILE" in os.environ:
histfile = os.path.expanduser(os.environ["PYTHONHISTFILE"])
elif "XDG_STATE_HOME" in os.environ:
histfile = os.path.join(os.path.expanduser(
os.environ["XDG_STATE_HOME"]), "python", "python_history")
else:
histfile = os.path.join(os.path.expanduser("~"), ".python_history")
histfile = os.path.abspath(histfile)
_dir, _ = os.path.split(histfile)
os.makedirs(_dir, exist_ok=True)
try:
readline.read_history_file(histfile)
except FileNotFoundError:
pass
atexit.register(readline.write_history_file, histfile)