git.plugin.zsh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 _git gup=git-fetch
  10. alias gp='git push'
  11. compdef _git gp=git-push
  12. gdv() { git-diff -w "$@" | view - }
  13. compdef _git gdv=git-diff
  14. alias gc='git commit -v'
  15. compdef _git gc=git-commit
  16. alias gca='git commit -v -a'
  17. compdef _git gca=git-commit
  18. alias gco='git checkout'
  19. compdef _git gco=git-checkout
  20. alias gb='git branch'
  21. compdef _git gb=git-branch
  22. alias gba='git branch -a'
  23. compdef _git gba=git-branch
  24. alias gcount='git shortlog -sn'
  25. compdef gcount=git
  26. alias gcp='git cherry-pick'
  27. compdef _git gcp=git-cherry-pick
  28. alias glg='git log --stat --max-count=5'
  29. compdef _git glg=git-log
  30. alias glgg='git log --graph --max-count=5'
  31. compdef _git glgg=git-log
  32. alias gss='git status -s'
  33. compdef _git gss=git-status
  34. alias ga='git add'
  35. compdef _git ga=git-add
  36. alias gm='git merge'
  37. compdef _git gm=git-merge
  38. # Git and svn mix
  39. alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
  40. compdef git-svn-dcommit-push=git
  41. alias gsr='git svn rebase'
  42. alias gsd='git svn dcommit'
  43. #
  44. # Will return the current branch name
  45. # Usage example: git pull origin $(current_branch)
  46. #
  47. function current_branch() {
  48. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  49. echo ${ref#refs/heads/}
  50. }
  51. # these aliases take advantage of the previous function
  52. alias ggpull='git pull origin $(current_branch)'
  53. compdef ggpull=git
  54. alias ggpush='git push origin $(current_branch)'
  55. compdef ggpush=git
  56. alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
  57. compdef ggpnp=git