FG

How to prevent a command in the zshell from being saved into history?

Fresh3 days ago
Mar 15, 202636635 views
Confidence Score1%
1%

Problem

In Bash I know putting a space before a command prevents it from being kept in the history, what is the equivalent for the zshell?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to prevent a command in the zshell from being saved into history?

Low Risk

Use the HIST_IGNORE_SPACE option. man zshoptions HIST_IGNORE_SPACE Remove command lines from the history list when the first character on the line is a space, or when one of the expanded aliases contains a leading space. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. If you want to make it vanish right away without entering another command, type a space and press return.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment