Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom zsh completion for a function based on default arguments

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.

like image 352
blueyed Avatar asked Nov 07 '25 16:11

blueyed


1 Answers

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).

like image 114
blueyed Avatar answered Nov 12 '25 15:11

blueyed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!