05cae34676ac3a22fb8a0adca8ab9b5301f48fb9

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

Message

Detect dependency plugins in candy-kingdom and kiwi themes

Fixes #5029
Fixes #5342

Diff

 1diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
 2index 30ce785c00dcc0f65722dabac5b71afbbee5ae06..ad03cc32076f2901688d4431285909cb8a31ead8 100644
 3--- a/themes/candy-kingdom.zsh-theme
 4+++ b/themes/candy-kingdom.zsh-theme
 5@@ -1,16 +1,14 @@
 6-# neuralsanwich.zsh-theme
 7-
 8-if [ "x$OH_MY_ZSH_HG" = "x" ]; then
 9-    OH_MY_ZSH_HG="hg"
10-fi
11-
12-function hg_prompt_info {
13-    $OH_MY_ZSH_HG prompt --angle-brackets "\
14+if ! hg prompt 2>/dev/null; then
15+    function hg_prompt_info { }
16+else
17+    function hg_prompt_info {
18+        hg prompt --angle-brackets "\
19 < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
20 < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
21 %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
22 patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
23-}
24+    }
25+fi
26 
27 function box_name {
28     [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
29@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
30 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
31 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
32 
33-local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
34-RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
35+RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}'
36+
37+# Add battery status if the battery plugin is enabled
38+if (( $+functions[battery_pct_prompt] )); then
39+    RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
40+fi
41diff --git a/themes/kiwi.zsh-theme b/themes/kiwi.zsh-theme
42index f93de2b75b3da25eab2d5d2ac0914f1ed52eb3b0..94f0ffcbf876bf991fe1cf65f30219475abdcc0f 100644
43--- a/themes/kiwi.zsh-theme
44+++ b/themes/kiwi.zsh-theme
45@@ -1,6 +1,4 @@
46-# 
47-# Kiwi ZSH Theme
48-# 
49+(( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { }
50 
51 PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt)
52 └> % %{$reset_color%}'