How do I tell zsh to correct simple spelling mistakes automatically?
For example:
I want lsbkl
to automatically be corrected to lsblk
, after hitting Enter, without showing zsh: correct 'lsbkl' to 'lsblk' [nyae]?
.
Is this possible to achieve?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHow do I tell zsh to correct simple spelling mistakes automatically?
For example:
I want lsbkl
to automatically be corrected to lsblk
, after hitting Enter, without showing zsh: correct 'lsbkl' to 'lsblk' [nyae]?
.
Is this possible to achieve?
This will autocorrect the word to the left of the cursor whenever you press Space or Enter:
autocorrect() {
zle .spell-word
zle .$WIDGET
}
zle -N accept-line autocorrect
zle -N magic-space autocorrect
bindkey ' ' magic-space