git.plugin.zsh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 gcm='git checkout master'
  21. alias gr='git remote'
  22. compdef _git gr=git-remote
  23. alias grv='git remote -v'
  24. compdef _git grv=git-remote
  25. alias grmv='git remote rename'
  26. compdef _git grmv=git-remote
  27. alias grrm='git remote remove'
  28. compdef _git grrm=git-remote
  29. alias grset='git remote set-url'
  30. compdef _git grset=git-remote
  31. alias grup='git remote update'
  32. compdef _git grset=git-remote
  33. alias gb='git branch'
  34. compdef _git gb=git-branch
  35. alias gba='git branch -a'
  36. compdef _git gba=git-branch
  37. alias gcount='git shortlog -sn'
  38. compdef gcount=git
  39. alias gcp='git cherry-pick'
  40. compdef _git gcp=git-cherry-pick
  41. alias glg='git log --stat --max-count=5'
  42. compdef _git glg=git-log
  43. alias glgg='git log --graph --max-count=5'
  44. compdef _git glgg=git-log
  45. alias gss='git status -s'
  46. compdef _git gss=git-status
  47. alias ga='git add'
  48. compdef _git ga=git-add
  49. alias gm='git merge'
  50. compdef _git gm=git-merge
  51. alias grh='git reset HEAD'
  52. alias grhh='git reset HEAD --hard'
  53. # Git and svn mix
  54. alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
  55. compdef git-svn-dcommit-push=git
  56. alias gsr='git svn rebase'
  57. alias gsd='git svn dcommit'
  58. #
  59. # Will return the current branch name
  60. # Usage example: git pull origin $(current_branch)
  61. #
  62. function current_branch() {
  63. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  64. echo ${ref#refs/heads/}
  65. }
  66. # these aliases take advantage of the previous function
  67. alias ggpull='git pull origin $(current_branch)'
  68. compdef ggpull=git
  69. alias ggpush='git push origin $(current_branch)'
  70. compdef ggpush=git
  71. alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
  72. compdef ggpnp=git