1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-14 00:50:08 +00:00

Pre-Grep the raw data to save some memory and to avoid cluttering up the output of setopt xtrace too much.

This commit is contained in:
Dominik Ritter 2015-11-24 18:17:04 +01:00
parent dad38b0592
commit c8137fcf1a

View file

@ -220,7 +220,9 @@ prompt_battery() {
[[ -z $POWERLEVEL9K_BATTERY_FOREGROUND ]] && local icon_color="$DEFAULT_COLOR_INVERTED" || local icon_color="$POWERLEVEL9K_BATTERY_FOREGROUND" [[ -z $POWERLEVEL9K_BATTERY_FOREGROUND ]] && local icon_color="$DEFAULT_COLOR_INVERTED" || local icon_color="$POWERLEVEL9K_BATTERY_FOREGROUND"
if [[ $OS =~ OSX && -f /usr/sbin/ioreg && -x /usr/sbin/ioreg ]]; then if [[ $OS =~ OSX && -f /usr/sbin/ioreg && -x /usr/sbin/ioreg ]]; then
local raw_data=$(ioreg -n AppleSmartBattery) # Pre-Grep all needed informations to save some memory and
# as little pollution of the xtrace output as possible.
local raw_data=$(ioreg -n AppleSmartBattery | grep -E "MaxCapacity|TimeRemaining|CurrentCapacity|ExternalConnected|IsCharging")
# return if there is no battery on system # return if there is no battery on system
[[ -z $(echo $raw_data | grep MaxCapacity) ]] && return [[ -z $(echo $raw_data | grep MaxCapacity) ]] && return