How to clear command history?

0373

To clear the command history in a terminal using the zsh shell, you can use the following commands:

  1. Clear the current session's history:

    history -c
  2. Remove the history file (if you want to clear the saved history):

    rm ~/.zsh_history
  3. Alternatively, you can also clear the history and then save the changes:

    history -c && history -w

Notes:

  • The history -c command clears the current session's history.
  • The rm ~/.zsh_history command deletes the history file, which means the history will be lost permanently.
  • After clearing the history, you may want to restart the terminal or run exec zsh to refresh the session.

Let me know if you need further assistance!

0 Comments

no data
Be the first to share your comment!