I have used zsh for a long time and I love autocompletion. For example, if I enter sudo dnf install fire and press TAB then it shows the possible results.
Today I have freshly installed fedora 41 and I couldn’t configure dnf autocompletion with zsh though it works with bash. Is there anything that I am missing?
I don’t use zsh.
However, while bash autocompletion functions are located here /usr/share/bash-completion/completions/dnf[1] and installed alongside dnf itself, zsh functions are located here /usr/share/zsh/5.9/functions
Zsh also provides dnf autocompletion… but… now we have dnf5 and looking at /usr/share/zsh/5.9/functions/_dnf
#compdef dnf dnf-2 dnf-3
#
# based on dnf-4.2.18
...
So, likely, it doesn’t work with dnf5, and nobody has still created autocompletion functions for zsh, maybe.
and notably /usr/share/bash-completion/completions/dnf5↩︎
Apparently there is a new dnf5 completion file for zsh that is WIP.
Have look at Re: dnf5 completions.
Make sure to read the whole conversion and not miss any updates.
just rename the file to _dnf and store it in your zsh completion functions directory.
for me it was located at: /usr/share/zsh/5.9/functions
Note: dont delete the old dnf4 _dnf file and store it as backup as _dnf.bak.
Thanks to Mikael Magnusson and few other developers for making this possible so soon.