I do some work in a single terminal tab:

> ls
> ps

Then I close the terminal, and open a new terminal, and run history

> history
    1  history

My .zsh file looks like this

setopt inc_append_history
setopt share_history

How can I make it preserve the history between tabs?


I have the same options and my history is shared. You can check that your zsh has those options set using setopt.

Also keep in mind that once you have added those setopt lines to your zsh you would need to source or create a new zsh session for them to take effect.


I think I figured it out.

I had HISTFILE specified in my .zprofile; but I had setopt share_history in my .zshrc. I moved the HISTFILE into the .zshrc, prior to the setopt line. Now it works fine. Thanks

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.