-
-
Save aaronmcadam/2639926 to your computer and use it in GitHub Desktop.
tweak for svn prompt in oh-my-zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
plugins/svn/svn.plugin.zsh | 30 ++++++++++++++++++------------ | |
1 files changed, 18 insertions(+), 12 deletions(-) | |
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh | |
index e2cf96c..b5b5265 100644 | |
--- a/plugins/svn/svn.plugin.zsh | |
+++ b/plugins/svn/svn.plugin.zsh | |
@@ -1,5 +1,6 @@ | |
function svn_prompt_info { | |
- if [ $(in_svn) ]; then | |
+ if in_svn; then | |
+ unset SVN_INFO | |
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ | |
$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" | |
fi | |
@@ -7,29 +8,34 @@ $ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_S | |
function in_svn() { | |
- if [[ -d .svn ]]; then | |
- echo 1 | |
- fi | |
+ test -d .svn | |
+} | |
+ | |
+function svn_get_info() { | |
+ if [ ! $SVN_INFO ]; then | |
+ SVN_INFO=$(svn info) | |
+ fi | |
+ echo "$SVN_INFO" | |
} | |
function svn_get_repo_name { | |
- if [ $(in_svn) ]; then | |
- svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT | |
+ if in_svn; then | |
+ svn_get_info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT | |
- svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" | |
+ svn_get_info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" | |
fi | |
} | |
function svn_get_rev_nr { | |
- if [ $(in_svn) ]; then | |
- svn info 2> /dev/null | sed -n s/Revision:\ //p | |
+ if in_svn; then | |
+ svn_get_info 2> /dev/null | sed -n s/Revision:\ //p | |
fi | |
} | |
function svn_dirty_choose { | |
- if [ $(in_svn) ]; then | |
- s=$(svn status|grep -E '^\s*[ACDIM!?L]' 2>/dev/null) | |
- if [ $s ]; then | |
+ if in_svn; then | |
+ svn status|grep -q -E '^\s*[ACDIM!?L]' 2>/dev/null | |
+ if [ $? ]; then | |
echo $1 | |
else | |
echo $2 | |
-- | |
1.7.4.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment