git-remote-branch.plugin.zsh 508 B

123456789101112131415161718
  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. compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
  10. elif (( CURRENT == 4 )); then
  11. # third arg: remote name
  12. compadd `git remote`
  13. fi
  14. else;
  15. _files
  16. fi
  17. }
  18. compdef _git_remote_branch grb