zsh: use completions for command X when I type command Y

前端 未结 1 829
闹比i
闹比i 2021-02-02 13:06

In zsh, I have a function called g which acts like this:

  • with no arguments, call git status
  • with one or more arguments, delegate
相关标签:
1条回答
  • 2021-02-02 13:33

    The documentation for compdef says this:

    The function compdef can be used to associate existing completion functions with new commands. For example,

    compdef _pids foo
    

    But adapting it (_git is the usual completion function for git) did not produce a working result for me (even after _git had been autoloaded):

    compdef _git g
    

    I was able to get it to work via _dispatch though:

    compdef '_dispatch git git' g
    
    0 讨论(0)
提交回复
热议问题