1

I'm using zsh and want the history tobehave like it does in bash. I have the following in my ~/.zshrc:

export FZF_BASE=/usr/bin/fzf
export HISTFILE=$HOME/.histfile
export SAVEHIST=500
export HISTSIZE=500
plugins=(
...
fzf
)

but for some reason, there is no ~/.histfile at all, why not? What else am I missing?

2
  • 1
    Apart from FZF_BASE, none of those variables need to be exported. This is not the issue though, but you may possibly find that the file is created after exiting an interactive zsh session. The history is only saved when the shell exits by default. I'm not turning this into a real answer since I don't know the circumstances under which you are testing this.
    – Kusalananda
    Oct 27 '20 at 22:31
  • @Kusalananda you can change your comment into an answer. I actually rebooted the machine and afterwards, it worked as expected!
    – stdcerr
    Oct 28 '20 at 7:05
1

As mentioned in comments, the zsh shell saves its command line history to the file referenced by the HISTFILE shell variable as soon as the shell terminates, but not before that by default. You would therefore not expect to see the file spring into existence until the termination of an interactive shell with HISTFILE set.

There shell options that you may set with setopt to write the shell's history to file after each command, e.g. INC_APPEND_HISTORY, INC_APPEND_HISTORY_TIME, or SHARE_HISTORY, but you should probably read about these and associated history-related shell options in the zshoptions manual (man zshoptions, then search for e.g. HIST).

Note that the history related shell variables (mentioned in the zshparam manual) are not environment variables, and that they therefore should not be exported.

-2

When one changes HISTFILE, in bash, and probably zsh, one must restart the history by setting HISTSIZE to 0, then the desired value.

HISTSIZE=0
HISTSIZE=500

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.