Skip to content

Conversation

@stefanoamorelli
Copy link

The current bash completion script uses bash-specific features like _init_completion and mapfile which don't exist in zsh. This causes zsh users to have no working completion for dnf5 1.

Previously, dnf4 shipped separate completion scripts for bash and zsh. This change restores that approach by adding a native zsh completion that uses dnf5's built-in --complete mechanism.

The implementation is intentionally minimal, using zsh's compadd to pass completions directly from dnf5's output. I tested more elaborate approaches with description parsing, but the simpler version proved more reliable across different zsh configurations.

Fixes #1826

@stefanoamorelli stefanoamorelli requested a review from a team as a code owner January 7, 2026 13:02
@stefanoamorelli stefanoamorelli requested review from pkratoch and removed request for a team January 7, 2026 13:02
The current bash completion script uses bash-specific features like
`_init_completion` and `mapfile` which don't exist in zsh. This causes
zsh users to have no working completion for dnf5, as reported in [1].

Previously, dnf4 shipped separate completion scripts for bash and zsh.
This commit restores that approach by adding a native zsh completion
that uses dnf5's built-in `--complete` mechanism.

The implementation is intentionally minimal, using zsh's `compadd` to
pass completions directly from dnf5's output. I tested more elaborate
approaches with description parsing, but the simpler version proved
more reliable across different zsh configurations.

Fixes: rpm-software-management#1826

[1]: rpm-software-management#1826
@kontura kontura self-assigned this Jan 19, 2026
@pkratoch
Copy link
Contributor

I don't normally use zsh and I don't know how the completion should be defined, but with trying out this patch, the completion adds \ character when completing commands and options and when the options are listed, there is also \ before every space and parenthesis, like this:

# dnf in
info\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(Lists\ packages\ depending\ on\ the\ packages\'\ relation\ to\ the\ system\ with\ additional\ details\)
install\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(Install\ software\)

# dnf install\  

That doesn't seem intentional.

Also, I can't reproduce the original bug anymore, possibly thanks to 66e2f4c , but maybe I am just missing something.

@kontura kontura removed their assignment Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autocomplete doesn't work on zsh

3 participants