问题
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