diff --git a/environment.d/10-profile.conf b/environment.d/10-profile.conf index 5651d37..ba1d542 100644 --- a/environment.d/10-profile.conf +++ b/environment.d/10-profile.conf @@ -18,7 +18,7 @@ GNUPGHOME="$XDG_CONFIG_HOME/gnupg" GOPATH="$XDG_DATA_HOME/go" NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" #PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass" -PYTHONHISTFILE="$XDG_DATA_HOME/python/histfile" +PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup" RUSTUP_HOME="$XDG_DATA_HOME/rustup" TERMINFO="$XDG_DATA_HOME/terminfo" TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo" diff --git a/python/startup b/python/startup new file mode 100644 index 0000000..8da7218 --- /dev/null +++ b/python/startup @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import atexit +import os +import readline + +xdg_cache_home = os.environ['XDG_CACHE_HOME'] + +if xdg_cache_home is None or xdg_cache_home == "": + xdg_cache_home = os.path.join(os.path.expanduser("~"), ".cache") + +python_cache_dir = os.path.join(xdg_cache_home, "python") +if not os.path.isdir(python_cache_dir): + os.mkdir(python_cache_dir) + +histfile = os.path.join(python_cache_dir, "history") + +try: + readline.read_history_file(histfile) + readline.set_history_length(10000) +except FileNotFoundError: + pass + +atexit.register(readline.write_history_file, histfile)