Skip to content

Backport: Add zsh support to completion script#1562

Open
gnodet wants to merge 1 commit intomvnd-1.xfrom
backport/zsh-completion-1.x
Open

Backport: Add zsh support to completion script#1562
gnodet wants to merge 1 commit intomvnd-1.xfrom
backport/zsh-completion-1.x

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Mar 17, 2026

Summary

Backport of #1559 to mvnd-1.x.

  • Auto-detect shell type (bash vs zsh) and set up bashcompinit for zsh compatibility
  • Replace bash-specific builtins (declare -F, compgen -v, ${!var}) with shell-conditional equivalents (typeset -f, typeset +, ${(P)var})
  • Accept both bash and zsh as --completion values
  • Update README to document zsh support

Cherry-picked cleanly from master commit 7f7db5e.

🤖 Generated with Claude Code

Make the existing bash completion script work in both bash and zsh
by auto-detecting the shell and adapting behavior accordingly:

- Add shell detection via $ZSH_VERSION / $BASH_VERSION
- Load bashcompinit in zsh for bash-style completion compatibility
- Use typeset instead of declare/compgen for zsh
- Use ${(P)var} instead of ${!var} for indirect expansion in zsh
- Accept 'zsh' as valid --completion argument in Completion.java
- Update README.adoc with zsh instructions

Based on the approach from PR #1514 by janweinschenker, consolidated
into the single existing script to avoid duplication.

Co-Authored-By: Jan Weinschenker <janweinschenker@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant