Zsh完成内引号 [英] Zsh completion inside quotes

查看:96
本文介绍了Zsh完成内引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的完成功能:

f()
{    
    reply=('ok')
}
compctl -K f c

然后我做

c

标签

c ok

某些方法有效.然后我在b

Something works. Then I do tab after b

c ok "a b"

什么也没有发生.我希望将a b替换为ok(就像在bash中一样).

and nothing happens. I expect a b to be replaced with ok (as it does in bash).

我该如何实现?

我真的需要在引号内进行补全.我的程序的典型启动如下所示:c 'a, &b, c[d]' 'a < 1 and b == "2013"'

I really need to do completions inside quotes. Typical launch of my program looks like this: c 'a, &b, c[d]' 'a < 1 and b == "2013"'

推荐答案

与引号的使用无关. zsh在第二种情况下不提供ok作为补全,因为它与已为该参数输入的内容相去甚远. c a之后也不会提供补全.

This has nothing to do with the use of quotes. zsh doesn't offer ok as a completion in your second case because it isn't anywhere close to what was already entered for that argument. The completion wouldn't be offered after c a either.

zsh通常假定要完成的内容将与已经输入的内容有些相关,从而使完成功能的作者无需检查匹配项.您可以在compctl命令中添加-U选项,以告知应使用整个$reply列表,即使条目不匹配也是如此.

zsh generally assumes that what is to be completed will be somewhat related to what has already been entered, relieving the author of a completion function from needing to check for matches. You can add the -U option to your compctl command to tell it that the entire $reply list should be used, even entries which don't match.

我还应该注意,compctl属于旧的zsh补全系统. zshcompsys联机帮助页

I should also note that compctl belongs to the old zsh completion system. The new completion system is described in the zshcompsys manpage

这篇关于Zsh完成内引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆