Improvements in Atomic theme

Operating system detection was added to show the percentage of the battery in the promt
pull/968/head
Luis Felipe Sánchez 2017-05-25 00:21:30 -05:00
parent f9c4f9e63a
commit 7a51ea23ee
1 changed files with 63 additions and 2 deletions

View File

@ -166,7 +166,48 @@ ___atomic_prompt_clock() {
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} }
___atomic_prompt_battery() { case "$OSTYPE" in
cygwin*) ___atomic_prompt_battery() {
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*')
bats=$(echo porcent=$(WMIC Path Win32_Battery Get BatteryStatus /Format:List) | grep -o '[0-9]*')
if [ "$batp" -gt 50 ]; then
color=$bold_green
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
color=$bold_yellow
elif [ "$batp" -lt 25 ]; then
color=$IRed
fi
box="[|]"
[ "$bats" -eq 1 ] && info="-"
[ "$bats" -eq 2 ] && info="+"
info+=$batp
[ "$info" == "+100" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} ;;
msys*) ___atomic_prompt_battery() {
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*')
bats=$(echo porcent=$(WMIC Path Win32_Battery Get BatteryStatus /Format:List) | grep -o '[0-9]*')
if [ "$batp" -gt 50 ]; then
color=$bold_green
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
color=$bold_yellow
elif [ "$batp" -lt 25 ]; then
color=$IRed
fi
box="[|]"
[ "$bats" -eq 1 ] && info="-"
[ "$bats" -eq 2 ] && info="+"
info+=$batp
[ "$info" == "+100" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} ;;
darwin*) ___atomic_prompt_battery() {
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] || [ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return [ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(battery_percentage) batp=$(battery_percentage)
@ -183,7 +224,27 @@ ___atomic_prompt_battery() {
info+=$batp info+=$batp
[ "$info" == "+100" ] && info="AC" [ "$info" == "+100" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} } ;;
linux*) ___atomic_prompt_battery() {
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(battery_percentage)
if [ "$batp" -gt 50 ]; then
color=$bold_green
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
color=$bold_yellow
elif [ "$batp" -lt 25 ]; then
color=$IRed
fi
box="[|]"
ac_adapter_disconnected && info="-"
ac_adapter_connected && info="+"
info+=$batp
[ "$info" == "+100" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} ;;
*) echo "bt:" ;;
esac
___atomic_prompt_exitcode() { ___atomic_prompt_exitcode() {
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return [ "${THEME_SHOW_EXITCODE}" != "true" ] && return