Reputation: 1356
I would like to disable Zsh history (arrow up) and zle history search (namely esc+p) completely. How can I achieve this?
My current .zshrc
:
unsetopt hist_append
unsetopt hist_expand
HISTFILE=
HISTSIZE=SAVEHIST=0
Currently I have history buffer of one, but I'd like to have history of zero.
21-10-2016 Update:
I've added
bindkey -r "^[p"
bindkey -r "^Xr"
bindkey -r "^Xs"
bindkey -r "^[[A"
bindkey -r "^[[B"
bindkey -r "^[n"
to get rid of history features that I use (esc+p is deeply hardwired to my backbone - so difficult to unlearn).
Upvotes: 5
Views: 8050
Reputation: 5317
I use following entries in my .zshrc
:
alias disablehistory="function zshaddhistory() { return 1 }"
If function zshaddhistory is defined, it can control whether history line will be saved.
Therefore, alias disablehistory
will just define function that always returns 1 (don't save).
alias disablehistory="function zshaddhistory() { return 1 }"
alias enablehistory="unset -f zshaddhistory"
enablehistory
just unsets function set by previous alias.
If you want to disable history completely, permanently define zshaddhistory
in your .zshrc
Upvotes: 8
Reputation: 967
Try configuring your ZSH setup to run a postexec function that empties/deletes your .zhistory file. It's a hacky workaround but should probably work.
Upvotes: 0
Reputation: 2058
I don't see anything in the zsh man page that completely disables history. Even setting HISTSIZE=0
seems to reset the value of HISTSIZE
to 1.
You'll probably have better luck changing the key bindings with bindkey
so that history features never occur. For example, bindkey -r "^[[A"
for my up-arrow key (note that I actually typed a caret and two brackets, not an escape key).
Upvotes: 2