git.plugin.zsh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. alias gd='git diff'
  13. gdv() { git diff -w "$@" | view - }
  14. compdef _git gdv=git-diff
  15. alias gc='git commit -v'
  16. compdef _git gc=git-commit
  17. alias gc!='git commit -v --amend'
  18. compdef _git gc!=git-commit
  19. alias gca='git commit -v -a'
  20. compdef _git gc=git-commit
  21. alias gca!='git commit -v -a --amend'
  22. compdef _git gca!=git-commit
  23. alias gco='git checkout'
  24. compdef _git gco=git-checkout
  25. alias gcm='git checkout master'
  26. alias gr='git remote'
  27. compdef _git gr=git-remote
  28. alias grv='git remote -v'
  29. compdef _git grv=git-remote
  30. alias grmv='git remote rename'
  31. compdef _git grmv=git-remote
  32. alias grrm='git remote remove'
  33. compdef _git grrm=git-remote
  34. alias grset='git remote set-url'
  35. compdef _git grset=git-remote
  36. alias grup='git remote update'
  37. compdef _git grset=git-remote
  38. alias gb='git branch'
  39. compdef _git gb=git-branch
  40. alias gba='git branch -a'
  41. compdef _git gba=git-branch
  42. alias gcount='git shortlog -sn'
  43. compdef gcount=git
  44. alias gcl='git config --list'
  45. alias gcp='git cherry-pick'
  46. compdef _git gcp=git-cherry-pick
  47. alias glg='git log --stat --max-count=5'
  48. compdef _git glg=git-log
  49. alias glgg='git log --graph --max-count=5'
  50. compdef _git glgg=git-log
  51. alias glgga='git log --graph --decorate --all'
  52. compdef _git glgga=git-log
  53. alias gss='git status -s'
  54. compdef _git gss=git-status
  55. alias ga='git add'
  56. compdef _git ga=git-add
  57. alias gm='git merge'
  58. compdef _git gm=git-merge
  59. alias grh='git reset HEAD'
  60. alias grhh='git reset HEAD --hard'
  61. alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
  62. alias gf='git ls-files | grep'
  63. alias gpoat='git push origin --all && git push origin --tags'
  64. # Will cd into the top of the current repository
  65. # or submodule.
  66. alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
  67. # Git and svn mix
  68. alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
  69. compdef git-svn-dcommit-push=git
  70. alias gsr='git svn rebase'
  71. alias gsd='git svn dcommit'
  72. #
  73. # Will return the current branch name
  74. # Usage example: git pull origin $(current_branch)
  75. #
  76. function current_branch() {
  77. ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  78. ref=$(git rev-parse --short HEAD 2> /dev/null) || return
  79. echo ${ref#refs/heads/}
  80. }
  81. function current_repository() {
  82. ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  83. ref=$(git rev-parse --short HEAD 2> /dev/null) || return
  84. echo $(git remote -v | cut -d':' -f 2)
  85. }
  86. # these aliases take advantage of the previous function
  87. alias ggpull='git pull origin $(current_branch)'
  88. compdef ggpull=git
  89. alias ggpush='git push origin $(current_branch)'
  90. compdef ggpush=git
  91. alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
  92. compdef ggpnp=git