autocomplete - zsh 完成:按子字符串而不是前缀匹配
问题描述
我为我的实用程序编写了一个有效的 ZSH 自动完成功能,_arguments
用于指定子命令,然后case
根据状态输入处理程序。
在$state
处理程序中,我_values
用来提供子命令可以使用的值。
_actions() {
local -a actions
actions=(
"start:Starts the specified service."
)
_describe "Subcommand" actions
}
_arguments \
'1: :_actions' \
'*: :->subcommand'
case "$state" in
subcommand)
domains=( com.example.foo com.example.bar )
_values "Domain" $domains
;;
esac
但是,for_values
的补全只是前缀。有什么方法_values
可以显示子字符串匹配?
我匹配的值是逆序 FQDN,例如com.example.foo
and com.example.bar
,我希望能够键入bar
、 hit 和已经com.example.bar
完成。
目前,我得到例如
$ mycommand start bar<TAB>
-- no matches found --
对比
$ mycommand start <TAB>
-- Domain --
com.example.bar com.example.foo
有什么方法可以做我想要实现的目标吗?_values
如果有一种方法可以通过某些功能定义自定义完成,我不依赖于此。
解决方案
推荐阅读
- android - 在输入密码之前通知用户要求的最佳方法是什么?
- powershell - 使用 powershell Get-Content 从文本文件中读取日期和时间
- sql-server - 如何限制用户从客户端本地计算机访问 SQL Server 数据库?
- plot - 如何在散景中设置轴标签和轴之间的距离?
- linux - 将所有 .tar 和 .tar.bz2 文件系统从所有子目录复制到另一个目录
- graph - 如何更改 Janusgraph 客户端读取一致性?
- sql - 创建函数“COPY EMPLOYEES_WITH_REC”,使用记录类型将数据从 EMPLOYEES 表复制到 JRF _EMPLOYEES 表
- c# - 如何检查鼠标是否在文本框中?
- python - 在 if 语句问题中初始化的变量范围
- google-apps-script - 自动重命名 Google 电子表格