Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Fwd: ZSH



On Sun, Mar 6, 2022, 5:18 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>
> Looping the mailing list back in.
>
> On Sun, Mar 6, 2022, at 12:51 AM, César Julio Estrada Pérez wrote:
> > Zsh save the wrong commands in .zsh_history file. How i can fix tis?
> >
> > For example:
> >
> > $gut clone / git clone
> > $sud apt updat / sudo apt update
>
> You still haven't clarified exactly what you mean by "wrong commands".

In the two cases above, "setopt correct" would give the opportunity to
fix the commands when they are executed, so the corrected versions are
what go into the history.

Commands are added to the history before execution is attempted, so
there's no opportunity to skip "wrong commands" no matter what that
specifically means.  If "setopt correct" won't suffice, the only
option would be to create a zshaddhistory hook that does its own
independent attempt to discover what's "wrong", such as (for example)
searching $path for ${{(z)1}[1]} (assuming the command line is not
"complex" such as a while-loop or if-else).




Messages sorted by: Reverse Date, Date, Thread, Author