From 55306bd85066e6f4101e98728ce5f9423f5d6fae Mon Sep 17 00:00:00 2001 From: Severin Kaderli Date: Wed, 13 Feb 2019 22:19:58 +0100 Subject: [PATCH] Move .python_history to a new location Signed-off-by: Severin Kaderli --- .gitignore | 2 +- install.sh | 1 + system/.config/custom/env | 6 +++++- system/.config/python/startup.py | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 system/.config/python/startup.py diff --git a/.gitignore b/.gitignore index 8876919..2c81144 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ system/.config/mpv/restore-old-bindings.conf .zcompdump system/.config/pulse/* -!system/.config/pulse/default.pa +!system/.config/pulse/default.pa \ No newline at end of file diff --git a/install.sh b/install.sh index 27d3f66..d6c9961 100755 --- a/install.sh +++ b/install.sh @@ -46,6 +46,7 @@ LINKED_FILES_HOME=( ".config/npm" ".config/polybar" ".config/pulse" + ".config/python" ".config/redshift" ".config/streamlink" ".config/termite" diff --git a/system/.config/custom/env b/system/.config/custom/env index 9db18b6..fef6aa2 100644 --- a/system/.config/custom/env +++ b/system/.config/custom/env @@ -36,6 +36,10 @@ export GEM_SPEC_CACHE="${XDG_CACHE_HOME}/gem/specs" mkdir -p "${XDG_DATA_HOME}/wine/prefixes" export WINEPREFIX="${XDG_DATA_HOME}/wine/prefixes/default" +# Python +mkdir -p "${XDG_DATA_HOME}/python" +export PYTHONSTARTUP="${XDG_CONFIG_HOME}/python/startup.py" + # zsh export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" export HISTFILE="${XDG_DATA_HOME}/zsh/history" @@ -47,7 +51,7 @@ compinit -d "${XDG_DATA_HOME}/zsh/zcompdump-${ZSH_VERSION}" # Setting applications export VISUAL=vim -export EDITOR="$VISUAL" +export EDITOR="${VISUAL}" export TERMINAL=termite # QT diff --git a/system/.config/python/startup.py b/system/.config/python/startup.py new file mode 100755 index 0000000..e19684a --- /dev/null +++ b/system/.config/python/startup.py @@ -0,0 +1,20 @@ +import atexit +import os +import readline + +XDG_DATA_HOME = os.environ["XDG_DATA_HOME"] + +if not XDG_DATA_HOME: + histfile = os.path.join(os.path.expanduser( + "~"), ".local", "share", "python", "history") +else: + histfile = os.path.join(XDG_DATA_HOME, "python", "history") + +try: + readline.set_auto_history(False) + readline.read_history_file(histfile) + readline.set_history_length(1000) +except FileNotFoundError: + pass + +atexit.register(readline.write_history_file, histfile)