Skip to content

feat(completion): add jq-backed zsh completion support. fixes #319#320

Open
jameswilson wants to merge 3 commits intomglaman:mainfrom
jameswilson:zsh-completion
Open

feat(completion): add jq-backed zsh completion support. fixes #319#320
jameswilson wants to merge 3 commits intomglaman:mainfrom
jameswilson:zsh-completion

Conversation

@jameswilson
Copy link
Contributor

Summary

This PR adds richer Zsh completion support for drupalorg by using drupalorg list --format=json when jq is available.

What Changed

  • rename the existing Bash completion file to drupalorg-cli-completion.bash for clarity that it is Bash-only.
  • add a dedicated drupalorg-cli-completion.zsh script for Zsh completions.
  • load command metadata from JSON and cache it for the current shell session
  • supported completions:
    • top-level commands and namespaces: eg drupalorg <TAB>, drupalorg issue:<TAB>
    • command aliases such as is: eg drupalorg i<TAB>
    • long and short options/flags: eg drupalorg is -<TAB>, drupalorg is --<TAB>
    • positional argument placeholders such as <nid> and [branch]: eg drupalorg is <TAB>
  • fallback to simpler command/namespace completion behavior when jq is unavailable
  • add README documentation for installing and using the Zsh completion script
  • add a self-contained regression test for the Zsh completion helpers

Testing

  • zsh tests/zsh-completion-tests.zsh

Related issues

Document how to install native Zsh completion via a _drupalorg
completion function. Zsh is the default shell on many macOS versions.

Fixes mglaman#319

Made-with: Cursor
- Rename existing completion file to clarify Bash-only compatibility.
- Create a sister completion file for Zsh.
- Update readme.
- load command metadata from drupalorg list --format=json
- cache parsed completion data for the current shell session
- complete aliases, options, and positional argument placeholders
- document the enhanced zsh behavior and placeholder meaning
- add regression coverage for the zsh completion helpers
@jameswilson
Copy link
Contributor Author

jameswilson commented Mar 16, 2026

Note: this PR is a workaround for an upstream-releated issue when using drupalorg completion from within a Zsh environment.

drupalorg completion zsh
Detected shell "zsh", which is not supported by Symfony shell completion (supported shells: "").

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