2

There's a way to setup zsh to not save commands not found to history ?

For example, if by mistake I type:

got push

instead of

git push

then got push entry is added to history file, how to stop this ?

Victor Aurélio
  • 653
  • 1
  • 9
  • 13
  • @mpy Actually not, the question is for failed commands which includes "not found" but includes also when the application return a status code different than `0`. I only want the "not found" to not be included in history. – Victor Aurélio Oct 02 '15 at 21:42
  • Despite of the possibly ambiguous linked question title, these Q&A do exactly cover this case: Failed command due to _command not found_ are omitted from history, while commands with return code > 0 _are_ stored. – mpy Oct 04 '15 at 10:41
  • Yeah now precise looking the title is ambiguous IMO. and sorry my bad, it solves thank you. – Victor Aurélio Oct 04 '15 at 12:42

1 Answers1

0

Command not found is an error. I don't think zsh differentiate this particular error with other errors, for example "missing parameter" etc.

The post might be helpful to you: Keep only successful commands in BASH history

SparedWhisle
  • 4,025
  • 1
  • 20
  • 30
  • IMHO, "not found" isn't the same as "missing parameter", since "not found" is when the executable isn't found in PATH while "missing parameter" is when executable is found in path and return status code other than 0. so I think a more specific workaround can be made. – Victor Aurélio Oct 01 '15 at 15:47