mercurial.plugin.zsh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. alias hglg='hg log --stat -v'
  21. alias hglgp='hg log --stat -p -v'
  22. function in_hg() {
  23. if $(hg branch > /dev/null 2>&1); then
  24. echo 1
  25. fi
  26. }
  27. function hg_get_branch_name() {
  28. branch=`hg branch 2>/dev/null`
  29. if [ $? -eq 0 ]; then
  30. echo $branch
  31. fi
  32. unset branch
  33. }
  34. function hg_prompt_info {
  35. _DISPLAY=`hg branch 2>/dev/null`
  36. if [ $? -eq 0 ]; then
  37. echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
  38. $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"
  39. fi
  40. unset _DISPLAY
  41. }
  42. function hg_dirty_choose {
  43. hg status -mar 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
  44. if [ $? -eq 0 ]; then
  45. if [ $pipestatus[-1] -eq 0 ]; then
  46. # Grep exits with 0 when "One or more lines were selected", return "dirty".
  47. echo $1
  48. return
  49. fi
  50. fi
  51. echo $2
  52. }
  53. function hg_dirty {
  54. hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN
  55. }
  56. function hgic() {
  57. hg incoming "$@" | grep "changeset" | wc -l
  58. }
  59. function hgoc() {
  60. hg outgoing "$@" | grep "changeset" | wc -l
  61. }
  62. function hg_get_bookmark_name() {
  63. if [ $(in_hg) ]; then
  64. echo $(hg id -B)
  65. fi
  66. }