Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何根据现有的完成定义和默认参数为函数设置完成。
一个简化的例子(可以重写为别名):
gpl() { git pull origin $@ }
这应该与 after 具有相同的完成git pull origin。
git pull origin
compdef -e 'words[1]=(git pull origin); service=git; (( CURRENT+=2 )); _git' ggl
这会按摩完成系统使用的$words,$service和$CURRENTvars,然后调用_git完成函数。
$words
$service
$CURRENT
_git
(感谢#zsh 上的 Mikachu)。