diff --git a/bash/.config/bash/rc b/bash/.config/bash/rc index ebe09d2..8f8da47 100644 --- a/bash/.config/bash/rc +++ b/bash/.config/bash/rc @@ -10,7 +10,8 @@ # Case-insensitive globbing (used in pathname expansion) shopt -s nocaseglob; -# Append to the Bash history file, rather than overwriting it +# Append to the Bash history file, rather than overwriting it. +# (HISTFILE/HISTSIZE/HISTFILESIZE/HISTCONTROL come from ~/.config/shell/exports.) shopt -s histappend; # Autocorrect typos in path names when using `cd` diff --git a/shell/.config/shell/exports b/shell/.config/shell/exports index 2603706..b530193 100644 --- a/shell/.config/shell/exports +++ b/shell/.config/shell/exports @@ -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" diff --git a/shell/.config/shell/interactive b/shell/.config/shell/interactive index e6f2b8c..81bc4f0 100644 --- a/shell/.config/shell/interactive +++ b/shell/.config/shell/interactive @@ -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 -)" diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 7fa9429..e1a8fd7 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -12,9 +12,9 @@ setopt autocd # Automatically cd into typed directory. stty stop undef # Disable ctrl-s to freeze terminal. setopt interactive_comments -# History in cache directory: -HISTSIZE=10000000 -SAVEHIST=10000000 +# HISTFILE/HISTSIZE/SAVEHIST come from ~/.config/shell/exports (shared). +# Dedup is a setopt, not an env var (bash's HISTCONTROL=ignoreboth equivalent): +setopt hist_ignore_all_dups hist_ignore_space # Basic auto/tab complete: autoload -U compinit