Set XDG vars for python

This commit is contained in:
ItsDrike 2023-08-02 01:45:32 +02:00
parent 08973fb001
commit be2013e4d4
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
5 changed files with 22 additions and 3 deletions

View file

@ -0,0 +1,18 @@
import atexit
import os
import readline
from pathlib import Path
cache_xdg_dir = Path(os.environ.get("XDG_CACHE_HOME", str(Path("~/.cache"))))
cache_xdg_dir.mkdir(exist_ok=True, parents=True)
history_file = cache_xdg_dir.joinpath("python_history")
readline.read_history_file(history_file)
def write_history() -> None:
readline.write_history_file(history_file)
atexit.register(write_history)