config/python: change history location at startup

This commit is contained in:
xeruf 2022-01-05 17:58:17 +01:00
parent bdc2e2c94e
commit 6613bfb1fd
2 changed files with 28 additions and 9 deletions

18
.config/pythonstartup.py Normal file
View File

@ -0,0 +1,18 @@
# https://unix.stackexchange.com/questions/630642/change-location-of-python-history
import os
import atexit
import readline
history = os.path.join(os.path.expanduser('~'), '.local/state/python_history')
try:
readline.read_history_file(history)
except OSError:
pass
def write_history():
try:
readline.write_history_file(history)
except OSError:
pass
atexit.register(write_history)

19
.zshenv
View File

@ -39,6 +39,7 @@ export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
export BUNDLE_USER_PLUGIN="$XDG_STATE_HOME"/bundle export BUNDLE_USER_PLUGIN="$XDG_STATE_HOME"/bundle
export PYTHONSTARTUP="$XDG_CONFIG_HOME"/pythonstartup.py
export LESSHISTFILE="$XDG_STATE_HOME"/lesshst export LESSHISTFILE="$XDG_STATE_HOME"/lesshst
export KSCRIPT_CACHE_DIR="$XDG_CACHE_HOME"/kscript export KSCRIPT_CACHE_DIR="$XDG_CACHE_HOME"/kscript
@ -50,16 +51,16 @@ export ANDROID_EMULATOR_HOME="$XDG_STATE_HOME"/android/emulator
export ANDROID_SDK_ROOT="/opt/android-sdk" export ANDROID_SDK_ROOT="/opt/android-sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin" export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin"
# taskwarrior & timewarrior # taskwarrior & timewarrior
export TIMEWARRIORDB="$XDG_DATA_HOME/timewarrior" export TIMEWARRIORDB="$XDG_DATA_HOME"/timewarrior
export TASKRC="$XDG_CONFIG_HOME/task/taskrc" export TASKRC="$XDG_CONFIG_HOME"/task/taskrc
export TASKDATA="$XDG_DATA_HOME/task" export TASKDATA="$XDG_DATA_HOME"/task
# zsh dirs # zsh dirs
export ZDOTDIR="$XDG_CONFIG_HOME/zsh" export ZDOTDIR="$XDG_CONFIG_HOME"/zsh
export ZSH="$XDG_DATA_HOME/zsh/oh-my-zsh" export ZSH="$XDG_DATA_HOME"/zsh/oh-my-zsh
export HISTFILE="$XDG_STATE_HOME/zsh/history" export HISTFILE="$XDG_STATE_HOME"/zsh/history
export CONFIG_ZSH="$XDG_CONFIG_HOME/zsh" export CONFIG_ZSH="$XDG_CONFIG_HOME"/zsh
export CONFIG_SHELLS="$XDG_CONFIG_HOME/shell" export CONFIG_SHELLS="$XDG_CONFIG_HOME"/shell
mkdir -p $XDG_STATE_HOME/zsh mkdir -p "$XDG_STATE_HOME/zsh"
# environment # environment
which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim' which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim'