1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

python: move .python_history to $XDG_CACHE_DIR/python

Courtesy of 89fd8cc648

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2020-08-23 11:17:01 +01:00
parent f16cd95a0f
commit be88417d59
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
2 changed files with 25 additions and 1 deletions

View File

@ -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"

24
python/startup Normal file
View File

@ -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)