-
Notifications
You must be signed in to change notification settings - Fork 11
Description
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:
-
Syntax:
- Bash uses the
completecommand for defining completions. - Zsh uses the
compdeffunction and the#compdefspecial comment.
- Bash uses the
-
Completion functions:
- In Bash, you typically define a function and then use
complete -Fto associate it with a command. - In Zsh, you define a function with a specific naming convention (usually
_commandname) and usecompdefto associate it.
- In Bash, you typically define a function and then use
-
Context awareness:
- Zsh's completion system is more context-aware and offers finer control over completions based on command position and argument type.
-
Completion specification:
- Zsh uses a more sophisticated completion specification system with tags and labels.
-
Built-in completion functions:
- Zsh provides many more built-in completion functions and utilities compared to Bash.
-
Performance:
- Zsh's completion system is generally faster and more efficient, especially for complex completions.
-
Customization:
- Zsh offers more extensive customization options for completion styles and behavior.
-
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?