有没有办法让 zsh 补全完全基于单词的前缀而不是后缀?
Is there a way to have zsh completion to be based entirely on the prefix of the word and not the suffix?
在 zsh 中,如果我写:
git --ver<tab>
它将完成到:
git --version
但如果我尝试完成:
git --ver<tab>asdf
它不会完成,因为它看到单词的其余部分不匹配任何可能的完成。有没有办法让它在完成时只考虑前缀而忽略后缀?
是的,有:设置 COMPLETE_IN_WORD
shell option and add the _prefix
completer:
autoload -Uz compinit; compinit
setopt completeinword
zstyle ':completion:*' completer \
_oldlist _expand _complete _correct _history _ignored _prefix
_prefix
将尝试在它之前出现的所有完成者,但不包括光标右侧的文本。
在 zsh 中,如果我写:
git --ver<tab>
它将完成到:
git --version
但如果我尝试完成:
git --ver<tab>asdf
它不会完成,因为它看到单词的其余部分不匹配任何可能的完成。有没有办法让它在完成时只考虑前缀而忽略后缀?
是的,有:设置 COMPLETE_IN_WORD
shell option and add the _prefix
completer:
autoload -Uz compinit; compinit
setopt completeinword
zstyle ':completion:*' completer \
_oldlist _expand _complete _correct _history _ignored _prefix
_prefix
将尝试在它之前出现的所有完成者,但不包括光标右侧的文本。