The history file for the zsh
shell is $HISTFILE
:
% ls -l $HISTFILE
-rw------- 1 kk kk 352704 May 8 14:16 /home/kk/.zsh_history
If this variable is unset, no history will be saved. There is no default value for this variable.
The shell has an in-memory history. This is what you scroll through with your arrow keys. The in-memory history will obviously be lost once the shell session terminates.
A possible value to set this variable to (in your .zshrc
file) is
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
i.e, to $ZDOTDIR/.zsh_history
if the variable ZDOTDIR
is defined and not empty, or to $HOME/.zsh_history
otherwise. This variable does not need to be exported as it is only used by the current shell session.
The ZDOTDIR
variable determines where the .zshrc
and other files are picked up from ($HOME
is used if ZDOTDIR
is not set).
You may also want to look up SAVEHIST
and other history-related shell variables in the zsh
manuals.