I am running Mojave have changed default shell from bash to zsh. I notice history is not saved between sessions.
Following recommendations in What are the practical differences between Bash and Zsh? I ran :
autoload -U zsh-newuser-install
zsh-newuser-install
This created the files ~/.zshrc
and ~/.histfile
which I did not have before but the history seems not to be updated.
A1398% cat .zshrc
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt beep
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/Users/hali/.zshrc'
autoload -Uz compinit
compinit
End of lines added by compinstall
A1398% cat .histfile
A1398%
On opening a new session (either Terminal or iTerm2) there is nothing previous and up arrow for previous commands does nothing.
Do I understand correctly and history should be in ~/.histfile
? Are there any other required steps?
exit
to terminate a shell session? – fd0 Nov 29 '19 at 20:07exit
was the answer. There appears to be some delay writing to .histfile andexit
flushes previous commands to the file. I was conflating the results of my missing .zshrc (which results in no history) with .histfile apparently not being updated. – lx07 Nov 30 '19 at 08:28