I have a custom alias for git that I use with git df
(it’s basically a shortcut for git diff
).
However, with git’s zsh autocorrect, everytime I use git df
in a directory that contains a db
directory, I get this:
% ls
app/ config/ db/ lib/ log/ spec/
% git alias | grep "df"
df = diff
% git df
zsh: correct 'df' to 'db' [nyae]?
Is there a way I could make zsh aware of my git aliases so it takes them into account when trying to autocorrect my commands? I want it to detect that git df
exist and not suggest me git db
instead.
I don’t want to create a zsh alias (eg. alias gdf="git diff"
) or use alias git="nocorrect git"
.
Thanks for your help!
You can force zsh to rebuild the autocorrect cache by running the command hash -rf
or rehash
. That fixed my problem when zsh was autocorrecting to the wrong thing.
Git has an autocorrect feature:
git config --global help.autocorrect
Will wait 2s before autocorrecting:
git config --global help.autocorrect 2
I think that if you want to implement this feature in zsh you will have to change the git completion function directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With