Skip to content

Commit

Permalink
Refactor HISTFILE setting
Browse files Browse the repository at this point in the history
Co-authored-by: WATANABE Yuki <magicant@wonderwand.net>
  • Loading branch information
unrealapex and magicant committed Sep 27, 2024
1 parent db35ff4 commit 42f70bc
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions share/initialization/common
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,18 @@ fi

# variables needed for command history

HISTFILE=${XDG_STATE_HOME:-~/.local/state}/yash/history
HISTSIZE=5000


# handle old yash history directory
if [ -f "$HOME/.yash_history" ] && [ -z "$HISTFILE" ]; then
echo 'warning: Yash does not read $HOME/.yash_history by default, please set
$HISTFILE to $XDG_STATE_HOME/yash/history'
HISTFILE="$HOME/.yash_history"
if ! [ "${HISTFILE-}" ]; then
HISTFILE=${XDG_STATE_HOME:-~/.local/state}/yash/history

# handle old default history path
if [ -f ~/.yash_history ]; then
printf 'Note: The default history file location has been changed to "%s".\n' "$HISTFILE" >&2
HISTFILE=~/.yash_history
printf 'Please consider moving the existing file from the current location "%s".\n' "$HISTFILE" >&2
fi
fi

# create HISTFILE directory if it doesn't exist
if [ ! -d "$(dirname "$HISTFILE")" ]; then
mkdir -p "$(dirname "$HISTFILE")"
fi
HISTSIZE=5000

# HISTRMDUP makes prediction less accurate
# HISTRMDUP=500
Expand Down

0 comments on commit 42f70bc

Please sign in to comment.