git-remote-branch.plugin.zsh 572 B

12345678910111213141516171819
  1. _git_remote_branch() {
  2. ref=$(git symbolic-ref HEAD 2> /dev/null)
  3. if [[ -n $ref ]]; then
  4. if (( CURRENT == 2 )); then
  5. # first arg: operation
  6. compadd create publish rename delete track
  7. elif (( CURRENT == 3 )); then
  8. # second arg: remote branch name
  9. remotes=`git remote | tr '\n' '|' | sed "s/\|$//g"`
  10. compadd `git branch -r | grep -v HEAD | sed "s/$remotes\///" | sed "s/ //g"`
  11. elif (( CURRENT == 4 )); then
  12. # third arg: remote name
  13. compadd `git remote`
  14. fi
  15. else;
  16. _files
  17. fi
  18. }
  19. compdef _git_remote_branch grb