git.plugin.zsh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Aliases
  2. alias g='git'
  3. compdef g=git
  4. alias gst='git status'
  5. compdef _git gst=git-status
  6. alias gl='git pull'
  7. compdef _git gl=git-pull
  8. alias gup='git fetch && git rebase'
  9. compdef gup=git
  10. alias gp='git push'
  11. compdef _git gp=git-push
  12. alias gd='git diff | mate'
  13. # WTF is mate??
  14. compdef _git gd=git-diff
  15. gdv() { git diff -w "$@" | view - }
  16. compdef gdv=git
  17. alias gc='git commit -v'
  18. compdef gc=git
  19. alias gca='git commit -v -a'
  20. compdef gca=git
  21. alias gco='git checkout'
  22. compdef _git gco=git-checkout
  23. alias gb='git branch'
  24. compdef _git gb=git-branch
  25. alias gba='git branch -a'
  26. compdef gba=git
  27. alias gcount='git shortlog -sn'
  28. compdef gcount=git
  29. alias gcp='git cherry-pick'
  30. compdef _git gcp=git-cherry-pick
  31. alias glg='git log --stat --max-count=5'
  32. compdef _git glg=git-log
  33. # Git and svn mix
  34. alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
  35. compdef git-svn-dcommit-push=git
  36. #
  37. # Will return the current branch name
  38. # Usage example: git pull origin $(current_branch)
  39. #
  40. function current_branch() {
  41. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  42. echo ${ref#refs/heads/}
  43. }
  44. # these aliases take advantage of the previous function
  45. alias ggpull='git pull origin $(current_branch)'
  46. compdef ggpull=git
  47. alias ggpush='git push origin $(current_branch)'
  48. compdef ggpush=git
  49. alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
  50. compdef ggpnp=git