8bf8e1ecf9eeb4117b1196a5fd02d788979f05f7
- Author
- LFDM <1986gh@gmail.com>
- Committer
- LFDM <1986gh@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
2index e75f2159904fd5981b84f2cecff0619b3694e17e..2183010baecc3f67e8ec892e1f57be4c7280bae0 100644
3--- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh
4+++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
5@@ -1,4 +1,4 @@
6-# vim:ft=zsh ts=2 sw=2 sts=2
7+# vim:ft=zsh ts=2 sw=2 sts=2 et
8 #
9 # Faster alternative to the current SVN plugin implementation.
10 #
11@@ -10,57 +10,69 @@
12 # *** IMPORTANT *** DO NO USE with the simple svn plugin, this plugin acts as a replacement of it.
13
14 function svn_prompt_info() {
15- info=$(svn info 2>&1) || return; # capture stdout and stdout
16- in_svn=true
17- repo_need_upgrade="$(svn_repo_need_upgrade $info)"
18- svn_branch_name="$(svn_get_branch_name $info)"
19- svn_dirty="$(svn_dirty_choose)"
20- svn_repo_name="$(svn_get_repo_name $info)"
21- svn_rev="$(svn_get_revision $info)"
22+ local info
23+ info=$(svn info 2>&1) || return 1; # capture stdout and stderr
24+ local repo_need_upgrade=$(svn_repo_need_upgrade $info)
25
26- if [ ! -z $repo_need_upgrade ]; then
27- echo $ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX$ZSH_PROMPT_BASE_COLOR\
28-$repo_need_upgrade\
29-$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR
30- fi
31-
32- if [[ ${in_svn} == true && -z $repo_need_upgrade ]]; then
33- echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
34-$ZSH_THEME_REPO_NAME_COLOR${svn_branch_name}\
35-$ZSH_PROMPT_BASE_COLOR${svn_dirty}\
36-$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX\
37-$ZSH_PROMPT_BASE_COLOR"
38- fi
39+ if [ -n $repo_need_upgrade ]; then
40+ printf '%s%s%s%s%s%s%s\n' \
41+ $ZSH_PROMPT_BASE_COLOR \
42+ $ZSH_THEME_SVN_PROMPT_PREFIX \
43+ $ZSH_PROMPT_BASE_COLOR \
44+ $repo_need_upgrade \
45+ $ZSH_PROMPT_BASE_COLOR \
46+ $ZSH_THEME_SVN_PROMPT_SUFFIX \
47+ $ZSH_PROMPT_BASE_COLOR \
48+ else
49+ # something left for you to fix -
50+ # repo name and rev aren't used here, did you forget them?
51+ # especially since you set a repo name color
52+ # if the prompt is alright this way, leave it as is and just
53+ # delete the comment. The functions itself could stay imo,
54+ # gives others the chance to use them.
55+ printf '%s%s%s%s%s%s%s%s%s\n' \
56+ $ZSH_PROMPT_BASE_COLOR \
57+ $ZSH_THEME_SVN_PROMPT_PREFIX \
58+ $ZSH_THEME_REPO_NAME_COLOR \
59+ $(svn_get_branch_name $info)
60+ ${svn_branch_name}\
61+ $ZSH_PROMPT_BASE_COLOR
62+ $(svn_dirty_choose $info)
63+ $ZSH_PROMPT_BASE_COLOR
64+ $ZSH_THEME_SVN_PROMPT_SUFFIX\
65+ $ZSH_PROMPT_BASE_COLOR
66+ fi
67 }
68
69-
70 function svn_repo_need_upgrade() {
71- info=$1
72- [ -z "${info}" ] && info=$(svn info 2>&1)
73- if grep -q "E155036" <<< $info; then echo "E155036: upgrade repo with svn upgrade"; fi
74+ grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \
75+ echo "E155036: upgrade repo with svn upgrade"
76 }
77
78 function svn_get_branch_name() {
79- info=$1
80- [ -z "${info}" ] && info=$(svn info 2> /dev/null)
81- echo $info | grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | read SVN_URL
82- echo $SVN_URL
83+ echo ${1:-$(svn info 2> /dev/null)} |\
84+ grep '^URL:' | egrep -o '(tags|branches)/[^/]+|trunk' |\
85+ egrep -o '[^/]+$'
86 }
87
88 function svn_get_repo_name() {
89- info=$1
90- [ -z "${info}" ] && info=$(svn info 2> /dev/null)
91- echo $info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
92- echo $info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
93+ # I think this can be further cleaned up as well, not sure how,
94+ # as I can't test it
95+ local svn_root
96+ local info=${1:-$(svn info 2> /dev/null)}
97+ echo $info | sed 's/Repository\ Root:\ .*\///p' | read svn_root
98+ echo $info | sed "s/URL:\ .*$svn_root\///p"
99 }
100
101 function svn_get_revision() {
102- info=$1
103- [ -z "${info}" ] && info=$(svn info 2> /dev/null)
104- echo $info 2> /dev/null | sed -n s/Revision:\ //p