4

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.

blueyed
  • 27,102
  • 4
  • 75
  • 71

1 Answers1

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

blueyed
  • 27,102
  • 4
  • 75
  • 71
  • 1
    What does CURRENT+=2 do? (this is working for me, just trying to grok) – skarface Feb 19 '15 at 04:34
  • 3
    @skarface `CURRENT` is the current word being handled, and that increases it by `2` (because we inject them: from `ggl` (1 word) to `git pull origin` (3 words)). – blueyed Feb 24 '15 at 14:41