git.plugin.zsh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 pull --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 gb='git branch'
  22. compdef _git gb=git-branch
  23. alias gba='git branch -a'
  24. compdef _git gba=git-branch
  25. alias gcount='git shortlog -sn'
  26. compdef gcount=git
  27. alias gcp='git cherry-pick'
  28. compdef _git gcp=git-cherry-pick
  29. alias glg='git log --stat --max-count=5'
  30. compdef _git glg=git-log
  31. alias glgg='git log --graph --max-count=5'
  32. compdef _git glgg=git-log
  33. alias gss='git status -s'
  34. compdef _git gss=git-status
  35. alias ga='git add'
  36. compdef _git ga=git-add
  37. alias gm='git merge'
  38. compdef _git gm=git-merge
  39. alias grh='git reset HEAD'
  40. alias grhh='git reset HEAD --hard'
  41. alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
  42. # Will cd into the top of the current repository
  43. # or submodule.
  44. alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
  45. # Git and svn mix
  46. alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
  47. compdef git-svn-dcommit-push=git
  48. alias gsr='git svn rebase'
  49. alias gsd='git svn dcommit'
  50. #
  51. # Will return the current branch name
  52. # Usage example: git pull origin $(current_branch)
  53. #
  54. function current_branch() {
  55. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  56. echo ${ref#refs/heads/}
  57. }
  58. function current_repository() {
  59. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  60. echo $(git remote -v | cut -d':' -f 2)
  61. }
  62. # these aliases take advantage of the previous function
  63. alias ggpull='git pull origin $(current_branch)'
  64. compdef ggpull=git
  65. alias ggpush='git push origin $(current_branch)'
  66. compdef ggpush=git
  67. alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
  68. compdef ggpnp=git