Skip to content

.NET CLI Tab Completion - zsh not evaluating full expression #31706

@gsferreira

Description

@gsferreira

Following the instructions for Tab Completion with Zsh, I realized that the suggestions aren't correct when I'm looking for suggestions inside a command.

Example: dotnet add p suggests pack and publish instead of package.

After digging into it, I realized that the $words variables only capture the last word on the terminal instead of the complete expression.

To fix it, I have updated the snippet to:

# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
  local words
  read -Ac words
  local completions=("$(dotnet complete "$words")")

  reply=( "${(ps:\n:)completions}" )
}

compctl -K _dotnet_zsh_complete dotnet

I'm more than happy to open a PR if you agree with the solution.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions