Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index bc75c5cf9ad01bd58ef29c4d83782ce5a849baff..9f404088a0bf66a8cedc4b0b49f0a67f9d1ebb4f 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -1,20 +1,71 @@
6-if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
7- function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
8- function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
9- function battery_pct_prompt() {
10- b=$(battery_pct_remaining)
11- if [ $b -gt 50 ] ; then
12- color='green'
13- elif [ $b -gt 20 ] ; then
14- color='yellow'
15+###########################################
16+# Battery plugin for oh-my-zsh #
17+# Original Author: Peter hoeg (peterhoeg) #
18+# Email: peter@speartail.com #
19+###########################################
20+# Author: Sean Jones (neuralsandwich) #
21+# Email: neuralsandwich@gmail.com #
22+# Modified to add support for Apple Mac #
23+###########################################
24+
25+if [[ $(uname) -eq "Darwin" ]] ; then
26+
27+ function battery_pct_remaining() {
28+ if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
29+ typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
30+ typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
31+ integer i=$(((currentcapacity/maxcapacity) * 100))
32+ echo $i
33 else
34- color='red'
35+ echo "External Power"
36 fi
37- echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
38 }
39-else
40- error_msg='no battery'
41- function battery_pct_remaining() { echo $error_msg }
42- function battery_time_remaining() { echo $error_msg }
43- function battery_pct_prompt() { echo '' }
44+
45+ function battery_time_remaining() {
46+ if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
47+ timeremaining=$(ioreg -rc "AppleSmartBattery"| grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
48+ echo "~$((timeremaining / 60)):$((timeremaining % 60))"
49+ else
50+ echo "∞"
51+ fi
52+ }
53+
54+ function battery_pct_prompt () {
55+ if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
56+ b=$(battery_pct_remaining)
57+ if [ $b -gt 50 ] ; then
58+ color='green'
59+ elif [ $b -gt 20 ] ; then
60+ color='yellow'
61+ else
62+ color='red'
63+ fi
64+ echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
65+ else
66+ echo ""
67+ fi
68+ }
69+
70+elif [[ $(uname) -eq "Linux" ]] ; then
71+
72+ if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
73+ function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
74+ function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
75+ function battery_pct_prompt() {
76+ b=$(battery_pct_remaining)
77+ if [ $b -gt 50 ] ; then
78+ color='green'
79+ elif [ $b -gt 20 ] ; then
80+ color='yellow'
81+ else
82+ color='red'
83+ fi
84+ echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
85+ }
86+ else
87+ error_msg='no battery'
88+ function battery_pct_remaining() { echo $error_msg }
89+ function battery_time_remaining() { echo $error_msg }
90+ function battery_pct_prompt() { echo '' }
91+ fi
92 fi
93diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
94new file mode 100644
95index 0000000000000000000000000000000000000000..25aeb65974f4c491c4ca842c4fca5b6999828d60
96--- /dev/null
97+++ b/themes/candy-kingdom.zsh-theme
98@@ -0,0 +1,37 @@
99+# neuralsanwich.zsh-theme
100+#
101+# Author: Sean Jones
102+# URL: http://www.neuralsandwich.com
103+# Repo:
104+# Direct link:
105+# Create:
106+# Modified:
107+
108+if [ "x$OH_MY_ZSH_HG" = "x" ]; then
109+ OH_MY_ZSH_HG="hg"
110+fi
111+
112+function hg_prompt_info {
113+ $OH_MY_ZSH_HG prompt --angle-brackets "\
114+< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
115+< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
116+%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
117+patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
118+}
119+
120+function box_name {
121+ [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
122+}
123+
124+PROMPT='
125+%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}$(box_name)%{$reset_color%}:%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
126+%(?,,%{${fg_bold[white]}%}[%?]%{$reset_color%} )$ '
127+
128+ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[magenta]%}branch: "
129+ZSH_THEME_GIT_PROMPT_CLEAN=""
130+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
131+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
132+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
133+
134+local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
135+RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'