【发布时间】:2018-04-02 15:48:52
【问题描述】:
我正在尝试将完成添加到自定义 vs 函数,该函数基本上打开与参数匹配的第一个文件名。
可选(如果您想了解有关此功能的更多信息,可以在此处找到我的中等帖子 => https://medium.com/@victor.boissiere/how-to-quickly-open-files-with-your-editor-1a51b3fe21bf)
在我当前的文件夹中,我有以下内容:
./example.sh./custom/directory.sh./custom/example.sh
行为
vs direct<TAB> => 完成到custom/directory.sh SUCCESS
vs example<TAB> => vs
为什么它删除了参数并且不允许我在example.sh和custom/example.sh之间进行选择?
代码
_vs() {
local curcontext="$curcontext" state line expl
_arguments -C \
'*:: :->open_files'
case "$state" in
open_files)
local file=${words[CURRENT]}
compadd -U - `find . -type f -ipath "*$file*" | sed "s|^\./||"`
;;
esac
return 0
}
compdef _vs vs
【问题讨论】:
标签: zsh completion