ca8a5a0a84d4bb38c0a953e633a7ee446037a616

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

svn-fast-info: add README, reorg. plugin

Diff

  1diff --git a/plugins/svn-fast-info/README.md b/plugins/svn-fast-info/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..04c596fd8780e1e4fbe8e600199d5543cdc2de4f
  4--- /dev/null
  5+++ b/plugins/svn-fast-info/README.md
  6@@ -0,0 +1,55 @@
  7+# svn-fast-info plugin
  8+
  9+Faster alternative to the main SVN plugin implementation. Works with svn 1.6 and newer.
 10+Use as a drop-in replacement to the svn plugin, not as complementary.
 11+
 12+To use it, add `svn-fast-info` to the plugins array in your zshrc file:
 13+```zsh
 14+plugins=(... svn-fast-info)
 15+```
 16+
 17+It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
 18+It displays the current status of the local files (added, deleted, modified, replaced, or else...)
 19+
 20+Use `svn_prompt_info` method to display the svn repository status in your theme. 
 21+
 22+## Functions
 23+
 24+- `svn_prompt_info`: displays all the available information regarding the status of the svn repository.
 25+
 26+- `svn_repo_need_upgrade`: shows whether the repository needs upgrading. `svn_prompt_info` queries the
 27+  rest of functions or not based on the result of this function.
 28+
 29+- `svn_current_branch_name`: shows the current branch.
 30+
 31+- `svn_repo_root_name`: displays the repository root.
 32+
 33+- `svn_current_revision`: shows the currently checked-out revision.
 34+
 35+- `svn_status_info`: shows a bunch of symbols depending on the status of the files in the repository.
 36+
 37+## Options
 38+
 39+- `ZSH_THEME_SVN_PROMPT_PREFIX`: sequence displayed at the beginning of the prompt info output.
 40+
 41+- `ZSH_THEME_SVN_PROMPT_SUFFIX`: sequence displayed at the end of the prompt info output.
 42+
 43+- `ZSH_THEME_SVN_PROMPT_CLEAN`: sequence displayed when the status of the repository is clean.
 44+
 45+- `ZSH_THEME_SVN_PROMPT_ADDITIONS`: sequence displayed if there are added files in the repository.
 46+  **Default:** `+`.
 47+
 48+- `ZSH_THEME_SVN_PROMPT_DELETIONS`: sequence displayed if there are deleted files in the repository.
 49+  **Default:** `✖`.
 50+
 51+- `ZSH_THEME_SVN_PROMPT_MODIFICATIONS`: sequence displayed if there are modified files in the repository.
 52+  **Default:** `✎`.
 53+
 54+- `ZSH_THEME_SVN_PROMPT_REPLACEMENTS`: sequence displayed if there are replaced files in the repository.
 55+  **Default:** `∿`.
 56+
 57+- `ZSH_THEME_SVN_PROMPT_UNTRACKED`: sequence displayed if there are untracked files in the repository.
 58+  **Default:** `?`.
 59+
 60+- `ZSH_THEME_SVN_PROMPT_DIRTY`: sequence displayed if the repository is dirty.
 61+  **Default:** `!`.
 62diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
 63index fe52653151e1d1f226469660d5130c6f5b043451..f40a59685f493b925043d8fd94d177f74a1516cc 100644
 64--- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh
 65+++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
 66@@ -1,17 +1,6 @@
 67-# vim:ft=zsh ts=2 sw=2 sts=2 et
 68-#
 69-# Faster alternative to the current SVN plugin implementation.
 70-#
 71-# Works with svn 1.6, 1.7, 1.8.
 72-# Use `svn_prompt_info` method to enquire the svn data.
 73-# It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
 74-# It displays the current status of the local files (added, deleted, modified, replaced, or else...)
 75-#
 76-# Use as a drop-in replacement of the svn plugin not as complementary plugin
 77-
 78 function svn_prompt_info() {
 79   local info
 80-  info=$(svn info 2>&1) || return 1; # capture stdout and stderr
 81+  info=$(svn info 2>&1) || return 1 # capture stdout and stderr
 82   local repo_need_upgrade=$(svn_repo_need_upgrade $info)
 83 
 84   if [[ -n $repo_need_upgrade ]]; then
 85@@ -27,7 +16,6 @@ function svn_prompt_info() {
 86     printf '%s%s%s%s %s%s%s:%s%s%s%s' \
 87       "$ZSH_PROMPT_BASE_COLOR" \
 88       "$ZSH_THEME_SVN_PROMPT_PREFIX" \
 89-      \
 90       "$(svn_status_info $info)" \
 91       "$ZSH_PROMPT_BASE_COLOR" \
 92       \
 93@@ -37,14 +25,13 @@ function svn_prompt_info() {
 94       \
 95       "$(svn_current_revision $info)" \
 96       "$ZSH_PROMPT_BASE_COLOR" \
 97-      \
 98       "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
 99       "$ZSH_PROMPT_BASE_COLOR"
100   fi
101 }
102 
103 function svn_repo_need_upgrade() {
104-  grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \
105+  grep -q "E155036" <<< "${1:-$(svn info 2> /dev/null)}" && \
106     echo "E155036: upgrade repo with svn upgrade"
107 }
108 
109@@ -63,12 +50,23 @@ function svn_current_revision() {
110 function svn_status_info() {
111   local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
112   local svn_status="$(svn status 2> /dev/null)";
113-  if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
114-  if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi
115-  if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi
116-  if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi
117-  if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
118-  if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"; fi
119+  if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then
120+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"
121+  fi
122+  if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then
123+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"
124+  fi
125+  if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then
126+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"
127+  fi
128+  if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then
129+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"
130+  fi
131+  if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then
132+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"
133+  fi
134+  if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then
135+    svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"
136+  fi
137   echo $svn_status_string
138 }
139-