How do you use an existing completion for a function in zsh?

If I write a zsh function like this

function git_checkout_with_selecta() {
  if [[ -z $1 ]]; then
    git checkout `git branch --no-merged | selecta`
  else
    git checkout "$@"
  fi
}
alias gco='git_checkout_with_selecta'

How can I apply the same tab completions that I have for 'git checkout' to the alias for the function 'gco'?


compdef _git gco=git-checkout

这将使用_git完成函数,并将git-checkout为service / sub-command。


Something like:

compdef gco=git 

If your completer triggers on git.

链接地址: http://www.djcxy.com/p/16712.html

上一篇: JVM核心线程

下一篇: 你如何使用zsh中的函数的现有完成?