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)

View file

@ -44,6 +44,9 @@ export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"
export NUGET_PACKAGES="$XDG_CACHE_HOME/NuGetPackages"
export PARALLEL_HOME="$XDG_CONFIG_HOME/parallel"
export RANDFILE="$XDG_CACHE_HOME/rnd"
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc.py"
export PYTHONPYCACHEPREFIX="$XDG_CACHE_HOME/python"
export PYTHONUSERBASE="$XDG_DATA_HOME/python"
# Less commonly used applications
export _ZL_DATA="$XDG_DATA_HOME/zlua"
export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history"

View file

@ -1 +0,0 @@
.cache/python_history

View file

@ -62,8 +62,7 @@ pyenv install -l | cut -d' ' -f3 | grep -E '^3\.6\.[0-9]+$' | tail -n 1 | xargs
# Copy other user configurations
mkdir -p ~/.local
cp -ra home/.local/bin ~/.local
cp -a home/.python_history ~
touch ~/.cache/python_history
cp -ra home/.config/python ~/.config
install -m 700 -d ~/.local/share/gnupg
mkdir -p ~/.local/share/npm/lib
cp -ra home/.config/btop ~/.config