【发布时间】:2011-12-04 02:48:56
【问题描述】:
我使用compctl -K _my_cpl ls 将我的自动完成功能与ls 命令挂钩。该函数从索引文件中返回名称列表。
但是,zsh 总是在每次完成后添加一个空格。如果我想自动完成多级目录,我每次都必须删除一个空格。 有没有办法像 bash 完成命令中的 -o nospace 选项一样删除额外的空间?
我测试了zstyle ':completion:*' add-space false 命令,但它不起作用。谢谢。
_my_cpl() {
local cur last opts
# current word in command line.
read -cA cur
last=$cur[-1]
# grep all directories and file names under current directory level.
opts=`egrep "${last}[^/]*[$|/]*" ~/index -o |uniq`
reply=($=opts)
}
compctl -K _my_cpl ls
【问题讨论】:
-
zsh 有一个 bashcompinit 模块。我可以将我的 bash 完整功能移植到 zsh 作为解决方法。自动加载 bashcompinit bashcompinit
标签: autocomplete zsh