664b97a3c8fc167bda2c64e48b18b27de8dce4cd

Author
Robin Ramael <robin.ramael@gmail.com>
Committer
Robin Ramael <robin.ramael@gmail.com>
Date

Message

Added svn info in prompt with plugin.

If the svn plugin is used, svn info (repo name and wether the repo is dirty) is displayed in the prompt like with git. Just lke with git, the colors can be manipulated with variables (see awesomepanda theme for example).

Diff

 1diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..45d4613069dafba044eece540faaf74266422b9e
 4--- /dev/null
 5+++ b/plugins/svn/svn.plugin.zsh
 6@@ -0,0 +1,42 @@
 7+function svn_prompt_info {
 8+    if [[ -d .svn ]]; then
 9+        echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
10+$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"
11+    fi
12+}
13+
14+
15+function in_svn() {
16+    if [[ -d .svn ]]; then
17+        echo 1
18+    fi
19+}
20+
21+function svn_get_repo_name {
22+    if [ is_svn ]; then
23+        svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
24+    
25+        svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//"
26+    fi
27+}
28+
29+function svn_get_rev_nr {
30+    if [ is_svn ]; then
31+        svn info 2> /dev/null | sed -n s/Revision:\ //p
32+    fi
33+}
34+
35+function svn_dirty_choose {
36+    if [ is_svn ]; then
37+        s=$(svn status 2>/dev/null)
38+        if [ $s ]; then 
39+            echo $1
40+        else 
41+            echo $2
42+        fi
43+    fi
44+}
45+
46+function svn_dirty {
47+    svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
48+}
49diff --git a/themes/awesomepanda.zsh-theme b/themes/awesomepanda.zsh-theme
50new file mode 100644
51index 0000000000000000000000000000000000000000..411b898371ade495a7924e6cd871d8f442d13b82
52--- /dev/null
53+++ b/themes/awesomepanda.zsh-theme
54@@ -0,0 +1,18 @@
55+# the svn plugin has to be activated for this to work.
56+
57+PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
58+
59+ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
60+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
61+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%})%{$fg[yellow]%} ✗ %{$reset_color%}"
62+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}) "
63+
64+
65+
66+ZSH_PROMPT_BASE_COLOR="%{$fg_bold[blue]%}"
67+ZSH_THEME_REPO_NAME_COLOR="%{$fg_bold[red]%}"
68+
69+ZSH_THEME_SVN_PROMPT_PREFIX="svn:("
70+ZSH_THEME_SVN_PROMPT_SUFFIX=")"
71+ZSH_THEME_SVN_PROMPT_DIRTY="%{$fg[red]%} ✘ %{$reset_color%}"
72+ZSH_THEME_SVN_PROMPT_CLEAN=" "