I have following answer for How to remove a single line from history?. When I do following, the line ( echo hello_world) is not saved into history. Please note that I am using zsh shell.
prompt$ echo hello_world
> # ^ extra space
$ history | tail -n1
1280 history | tail -n
$ echo hello_world
hello_world
$ history | tail -n1
1280 history | tail -n
But when I do run a command having a space at the beginning and right after do Ctrl+P, I can see it on the shell history, even though it is not save in history. Is it possible to prevent it? With the bash shell, this works when setting HISTCONTROL= ignorespace.
$ echo hello_world
$ # Press `CTRL-p` => " echo hello_world" shows up again
Setup: I have following configuration for the
zsh shell:
## Save only one command if 2 common are same and consistent
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
## Delete empty lines from history file
setopt HIST_REDUCE_BLANKS
## Ignore a record starting with a space
setopt HIST_IGNORE_SPACE
## Do not add history and fc commands to the history
setopt HIST_NO_STORE
## Add timestamp for each entry
setopt EXTENDED_HISTORY