Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • What history-related shell options are you using? Are you, for example, sharing history between shell sessions with setopt SHARE_HISTORY or are you using setopt INC_APPEND_HISTORY (both of these writes commands to the history as they are entered)? Commented Sep 29, 2019 at 22:45
  • I am using setopt APPEND_HISTORY. I'm quite happy with how that works, it appends the current session's history to the $HISTFILE whenever the terminal is closed. But sometimes I want to clear the history during the session (when I write something stupid), but preserve what is in $HISTFILE Commented Sep 29, 2019 at 22:47
  • 5
    are you looking for history -p? Commented Dec 16, 2019 at 15:39
  • It seems like you could use the title like: "How to reset the zsh histroy to a predefined set when I login", otherwise you will keep seeing "history -p" around Commented Jan 5, 2022 at 2:16