Skip to content

How to clear command history in zsh

homepage-banner

Introduction

Zsh is a powerful shell with many features that make it a popular choice among developers. One of its features is the command history, which allows users to easily access and reuse previously executed commands. However, there may be times when you want to clear your command history. In this blog post, we will discuss how to clear command history in zsh.

Using the Command Line

In zsh, you can clear the command history by using the following command instead of history -c:

history -p

Using the Zsh History File

Zsh stores your command history in a file called .zsh_history. To clear your command history using the history file, follow these steps:

  1. Open the .zsh_history file in your favorite text editor.
  2. Delete all the entries in the file.
  3. Save the file and exit the text editor.

This will clear all the entries in your command history file, which means that your command history will be empty.

Leave a message