Custom zsh completion for a function based on default arguments

最后都变了- 提交于 2019-11-29 23:06:54

问题


How can I setup completion for a function, based on existing completion definitions and default arguments.

A simplified example (which could be rewritten as an alias):

gpl() {
    git pull origin $@
}

This should have the same completion as after git pull origin.


回答1:


compdef -e 'words[1]=(git pull origin); service=git; (( CURRENT+=2 )); _git' ggl

This massages the $words, $service and $CURRENT vars used by the completion system, and then calls the _git completion function.

(Thanks to Mikachu on #zsh).



来源:https://stackoverflow.com/questions/27226716/custom-zsh-completion-for-a-function-based-on-default-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!