Zsh completion inside quotes

不羁岁月 提交于 2019-12-13 04:30:42

问题


Here is my completion function:

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

Then I do

c

tab

c ok

Something works. Then I do tab after b

c ok "a b"

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

How could I achieve it?

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"'


回答1:


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 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.

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



来源:https://stackoverflow.com/questions/18126034/zsh-completion-inside-quotes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!