Skip to content

Support for ZSH #9

@closedLoop

Description

@closedLoop

So I'd love to support zsh as well as bash

From Claude:
Yes, there are several key differences between how Bash and Zsh implement command-line completions. Here are some of the main points to consider when migrating a bash_completion script to Zsh:

  1. Syntax:

    • Bash uses the complete command for defining completions.
    • Zsh uses the compdef function and the #compdef special comment.
  2. Completion functions:

    • In Bash, you typically define a function and then use complete -F to associate it with a command.
    • In Zsh, you define a function with a specific naming convention (usually _commandname) and use compdef to associate it.
  3. Context awareness:

    • Zsh's completion system is more context-aware and offers finer control over completions based on command position and argument type.
  4. Completion specification:

    • Zsh uses a more sophisticated completion specification system with tags and labels.
  5. Built-in completion functions:

    • Zsh provides many more built-in completion functions and utilities compared to Bash.
  6. Performance:

    • Zsh's completion system is generally faster and more efficient, especially for complex completions.
  7. Customization:

    • Zsh offers more extensive customization options for completion styles and behavior.
  8. Caching:

    • Zsh has built-in caching mechanisms for completions, which can improve performance for expensive operations.

When migrating your script, you'll need to rewrite your completion logic using Zsh's completion system. This often involves using Zsh-specific functions like _arguments, _describe, _values, and others.

Would you like me to provide an example of how to structure a basic Zsh completion function? Or do you have any specific aspects of your Bash completion script that you'd like guidance on converting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions