shell: centralize history config and create history dir

Move HISTFILE/HISTSIZE/SAVEHIST/HISTFILESIZE/HISTCONTROL into the shared
shell/exports as env vars; each shell ignores the other's name-specific
ones. Dedup that can't be an env var stays per-shell: HISTCONTROL=ignoreboth
for bash, setopt hist_ignore_all_dups/hist_ignore_space for zsh.

Also mkdir -p the HISTFILE parent in shell/interactive, so a fresh host
doesn't silently drop history when ~/.cache/shell is absent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-29 11:49:55 +02:00
parent 634f4950f0
commit ad5a6c98ea
4 changed files with 16 additions and 5 deletions
+7 -1
View File
@@ -7,8 +7,14 @@ export XDG_CACHE_HOME="$HOME/.cache"
# Default editor
export EDITOR='vim'
# Shell history file
# Shell history (env vars both shells read; each ignores the other's by name —
# zsh uses SAVEHIST, bash uses HISTFILESIZE/HISTCONTROL. zsh dedup is a setopt,
# not an env var, so it stays in .zshrc).
export HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/shell/history"
export HISTSIZE=1000000 # commands kept in memory (both shells)
export SAVEHIST=1000000 # zsh: lines written to $HISTFILE
export HISTFILESIZE=1000000 # bash: lines written to $HISTFILE
export HISTCONTROL=ignoreboth # bash: drop dups + space-prefixed
# Global git config file
export GIT_CONFIG_GLOBAL="${XDG_CONFIG_HOME:-$HOME/.config}/git/config"
+4
View File
@@ -8,5 +8,9 @@ for _file in "${XDG_CONFIG_HOME:-$HOME/.config}"/shell/{aliases,functions,extra}
done
unset _file
# Ensure the history dir exists; neither shell mkdir's it, so without this
# $HISTFILE writes fail silently on a fresh host.
[ -n "$HISTFILE" ] && mkdir -p "$(dirname "$HISTFILE")"
# pyenv interactive shims (pyenv init - autodetects the running shell):
command -v pyenv >/dev/null 2>&1 && eval "$(pyenv init -)"