mercurial.plugin.zsh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # aliases
  2. alias hga='hg add'
  3. alias hgc='hg commit'
  4. alias hgca='hg commit --amend'
  5. alias hgb='hg branch'
  6. alias hgba='hg branches'
  7. alias hgbk='hg bookmarks'
  8. alias hgco='hg checkout'
  9. alias hgd='hg diff'
  10. alias hged='hg diffmerge'
  11. alias hgp='hg push'
  12. alias hgs='hg status'
  13. alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"'
  14. alias hgun='hg resolve --list'
  15. # pull and update
  16. alias hgi='hg incoming'
  17. alias hgl='hg pull -u'
  18. alias hglr='hg pull --rebase'
  19. alias hgo='hg outgoing'
  20. function in_hg() {
  21. if $(hg branch > /dev/null 2>&1); then
  22. echo 1
  23. fi
  24. }
  25. function hg_get_branch_name() {
  26. branch=`hg branch 2>/dev/null`
  27. if [ $? -eq 0 ]; then
  28. echo $branch
  29. fi
  30. unset branch
  31. }
  32. function hg_prompt_info {
  33. _DISPLAY=`hg branch 2>/dev/null`
  34. if [ $? -eq 0 ]; then
  35. echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
  36. $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"
  37. fi
  38. unset _DISPLAY
  39. }
  40. function hg_dirty_choose {
  41. hg status -mar 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
  42. if [ $? -eq 0 ]; then
  43. if [ $pipestatus[-1] -eq 0 ]; then
  44. # Grep exits with 0 when "One or more lines were selected", return "dirty".
  45. echo $1
  46. return
  47. fi
  48. fi
  49. echo $2
  50. }
  51. function hg_dirty {
  52. hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN
  53. }
  54. function hgic() {
  55. hg incoming "$@" | grep "changeset" | wc -l
  56. }
  57. function hgoc() {
  58. hg outgoing "$@" | grep "changeset" | wc -l
  59. }
  60. function hg_get_bookmark_name() {
  61. if [ $(in_hg) ]; then
  62. echo $(hg id -B)
  63. fi
  64. }