Custom zsh completion for a function based on defa

2020-02-29 06:53发布

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条回答
太酷不给撩
2楼-- · 2020-02-29 07:04
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).

查看更多
登录 后发表回答