git.plugin.zsh 3.0 KB

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