question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Native zsh completion

See original GitHub issue

Picocli currently can create bash completion files, and zsh has a compatibility tool to read bash completion files.

However, this only exposes basic autocompletion features (what bash itself support), and does not take advantage of the features zsh offer.

For instance, zsh can show a description for each command/option, as well as option aliases (short vs long options). There’s a thousands pictures on the internet; here’s one example for the git command:

screenshot from 2018-03-05 10-48-22

This behavior cannot be obtained from a bash completion file.

Therefore, I propose that a new Autocomplete.zsh static method be added, to output a zsh-native completion script that includes more details, like command and option description and aliases.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Nov 18, 2020

@yschimke I saw your message on #502. Thanks! I am still working on some parser issues, but ZSH completion is high on my list of priorities. Once I make some progress on this your feedback will be very welcome!

UPDATE 2020/11/16

I was thinking about redesigning the logic for generating completion scripts to follow the Visitor pattern; I need to prototype this a bit to see how useful this would be. Something like this:

interface ModelVisitor<R,P> {
  R visit(CommandSpec command, P p);
  R visit(ArgGroupSpec group, P p);
  R visit(OptionSpec option, P p);
  R visit(PositionalParamSpec positional, P p);
}

Current call tree:

bash(String, CommandLine)
  generateEntryPointFunction
    generateFunctionCallsToArrContains
      [generateFunctionCallsToArrContains...] - recursively for nested subcommands
  generateFunctionForCommand - for all subcommands and nested descendant sub-subcmds
    generateCompletionCandidates - options with completion candidates
    generateOptionsSwitch - other options for which completions can be generated
    generatePositionParamCompletionCandidates - positionals with completion candidates
    generatePositionalParamsCases - other positionals for which completions can be generated
Read more comments on GitHub >

github_iconTop Results From Across the Web

zsh auto-completion - Kubernetes
The kubectl completion script for Zsh can be generated with the command kubectl completion zsh . Sourcing the completion script in your shell ......
Read more >
Zsh - ArchWiki
Command completion. Perhaps the most compelling feature of Zsh is its advanced autocompletion abilities. At the very least, enable autocompletion in .zshrc ....
Read more >
Command completion - AWS Command Line Interface
When you partially enter a command, parameter, or option, the command-completion feature either automatically completes your command or displays a suggested ...
Read more >
Command completion - Amazon Command Line Interface
The Amazon Command Line Interface (Amazon CLI) includes a bash-compatible command-completion feature that enables you to use the Tab key to complete a ......
Read more >
IDE-style autocomplete for your zsh terminal - Reddit
Can it use existing native zsh completion code? ... full control over your terminal just can't ever weigh up against its feature set....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found