git.zsh 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # get the name of the branch we are on
  2. function git_prompt_info() {
  3. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  4. echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
  5. }
  6. parse_git_dirty () {
  7. if [[ -n $(git status -s 2> /dev/null) ]]; then
  8. echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
  9. else
  10. echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
  11. fi
  12. }
  13. #
  14. # Will return the current branch name
  15. # Usage example: git pull origin $(current_branch)
  16. #
  17. function current_branch() {
  18. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  19. echo ${ref#refs/heads/}
  20. }
  21. # Aliases
  22. alias g='git'
  23. alias gst='git status'
  24. alias gl='git pull'
  25. alias gup='git fetch && git rebase'
  26. alias gp='git push'
  27. alias gd='git diff | mate'
  28. alias gdv='git diff -w "$@" | vim -R -'
  29. alias gc='git commit -v'
  30. alias gca='git commit -v -a'
  31. alias gb='git branch'
  32. alias gba='git branch -a'
  33. alias gcount='git shortlog -sn'
  34. alias gcp='git cherry-pick'