ZSH完成fzf-tab do do dotnet命令不使用

发布于 2025-02-13 05:23:08 字数 1087 浏览 1 评论 0原文

我启用了ZSH完成,并通过Zinit添加了FZF-TAB。它可以按预期工作。我添加了一些自定义/额外的完成,例如AWS CLI,它也按预期工作。

但是,当我试图按照建议的dotnet启用完成时,它不适用于FZF。请参阅下面的屏幕截图以及我的.zshrc的代码完成。

我缺少什么时候让Dotnet CLI使用FZF-TAB完成菜单工作?

[![autoload bashcompinit; bashcompinit
autoload -Uz compinit; compinit

_comp_options+=(globdots) # With hidden files
_dotnet_zsh_complete()
{

local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )

}

compctl -K _dotnet_zsh_complete dotnet
complete -C "/usr/local/bin/aws_completer" aws][1]][1]

这就是使用系统命令的外观

这就是我按下时AWS CLI的外观

当我按下时,这就是使用dotnet cli的外观

I enabled zsh completion and added fzf-tab via zinit. It works as expected. I added some custom/extra completions e.g., aws cli and it also worked as expected.

However, when I tried to enable the completion for dotnet as recommended it didn't work with fzf. Please see the screenshots below and the code from my .zshrc for the completions.

What am I missing to get dotnet cli work with fzf-tab completion menu?

[![autoload bashcompinit; bashcompinit
autoload -Uz compinit; compinit

_comp_options+=(globdots) # With hidden files
_dotnet_zsh_complete()
{

local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )

}

compctl -K _dotnet_zsh_complete dotnet
complete -C "/usr/local/bin/aws_completer" aws][1]][1]

This is how it looks with system commands e.g., cp when I press TAB
enter image description here

This is how it looks with AWS CLI when I press TAB
AWS completion

This is how it looks with dotnet CLI when I press TAB
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

歌入人心 2025-02-20 05:23:08

您正在尝试使用旧的compctl方式,该方式与FZF-TAB无法使用。

用以下内容替换.zshrc中的配置:

# zsh parameter completion for the dotnet CLI

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

  # If the completion list is empty, just continue with filename selection
  if [ -z "$completions" ]
  then
    _arguments '*::arguments: _normal'
    return
  fi

  # This is not a variable assignment, don't remove spaces!
  _values = "${(ps:\n:)completions}"
}

compdef _dotnet_zsh_complete dotnet

https://learn.microsoft.com/en-us/dotnet/core/core/tools/enable-tab-autocomplete

You are trying to use the old compctl way, which does not work with fzf-tab.

Replace your config in .zshrc with this:

# zsh parameter completion for the dotnet CLI

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

  # If the completion list is empty, just continue with filename selection
  if [ -z "$completions" ]
  then
    _arguments '*::arguments: _normal'
    return
  fi

  # This is not a variable assignment, don't remove spaces!
  _values = "${(ps:\n:)completions}"
}

compdef _dotnet_zsh_complete dotnet

source: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文