-1

When I test with a variable like:

test="abc"

above command didn't save into history, must I have messed up with some setopt but I don't know which can be affect to this.

So what zsh history opts can prevent it from saving var into zsh history? I have HIST_NO_FUNCTIONS set that I suspect it.

EDIT: full setopt

autocd
autonamedirs
autopushd
extendedglob
extendedhistory
noglobalrcs
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histnofunctions
histnostore
histreduceblanks
histsavenodups
histverify
incappendhistory
interactive
interactivecomments
login
magicequalsubst
monitor
nonotify
nullglob
promptsubst
pushdignoredups
pushdminus
pushdsilent
pushdtohome
rmstarsilent
sharehistory
shinstdin
zle
Tuyen Pham
  • 1,805

1 Answers1

4

A few days ago, in another question, you said you had added to your ~/.zshrc:

zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }

That causes command lines whose first word (with quoting included) is not the name of any existing command not to be added to the history.

test="abc" is not the name of an existing command on your system, so it won't get saved in the history.

That would also fail to save a command line like "echo" "foo", or <input tr a b >output, or (foo; bar) | baz...

@Gilles had already warned you about that in a comment to your question there.

  • Seem true, I haven’t found a solution for excluding failed commands and force to add it to zshaddhistory. – Tuyen Pham May 24 '20 at 20:23