I have added
export HISTIGNORE="ls:cd:pwd:exit:cd .."
to my .zshrc file.
Deleted .zsh_history and restarted terminal but it still wont ignore those commands.

The zsh shell doesn't use the HISTIGNORE environment variable. Instead, it has a HISTORY_IGNORE environment variable.
From the zshparam manual:
HISTORY_IGNOREIf set, is treated as a pattern at the time history files are written. Any potential history entry that matches the pattern is skipped. For example, if the value is
fc *then commands that invoke the interactive history editor are never written to the history file.Note that
HISTORY_IGNOREdefines a single pattern: to specify alternatives use the(first|second|...)syntax.
So in your case, you would want to do
HISTORY_IGNORE="(ls|cd|pwd|exit|cd ..)"
or something similar.
Notice that this affects only history written to the history file, not the history in the currently active shell session, as far as I can see.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With