I am trying to ignore some sensitive commands from being saved in history file in zsh.
HISTSIZE=1000 # 1000 lines of history within the shell
SAVEHIST=1000 # 1000 lines of history in $HISTFILE
HISTFILE=${HOME}/.zsh_history # Save history to ~/.zsh_history
## Ignore save in $HISTFILE, but still in the shell
HISTORY_IGNORE='([bf]g *|cd ..|l[a,l,s,h,] *|less *|vi[m,] *)'
But it still shows in history file:
% rm .zsh_history
% ls
Desktop Documents Downloads Music peda Pictures Public Templates Videos
% l
Desktop/ Documents/ Downloads/ Music/ peda/ Pictures/ Public/ Templates/ Videos/
% cat .zsh_history
ls
l
cat .zsh_history
I have read the zshparam page but it doesn't help.
Is the part l[a,l,s,h,] *
right?
HISTORY_IGNORE
? – mja Jan 28 '18 at 03:15[[ $1 != ${~HISTORY_IGNORE} ]]
in the function on removing entries from history, and I think that test matches up pretty well with the actual behaviour ofHISTORY_IGNORE
on command lines – muru Jan 28 '18 at 03:18