svn.plugin.zsh 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function svn_prompt_info {
  2. if [ $(in_svn) ]; then
  3. echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
  4. $ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
  5. fi
  6. }
  7. function in_svn() {
  8. if [[ -d .svn ]]; then
  9. echo 1
  10. fi
  11. }
  12. function svn_get_repo_name {
  13. if [ $(in_svn) ]; then
  14. svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
  15. svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
  16. fi
  17. }
  18. function svn_get_rev_nr {
  19. if [ $(in_svn) ]; then
  20. svn info 2> /dev/null | sed -n s/Revision:\ //p
  21. fi
  22. }
  23. function svn_dirty_choose {
  24. if [ $(in_svn) ]; then
  25. s=$(svn status|grep -E '^\s*[ACDIM!?L]' 2>/dev/null)
  26. if [ $s ]; then
  27. echo $1
  28. else
  29. echo $2
  30. fi
  31. fi
  32. }
  33. function svn_dirty {
  34. svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
  35. }