Created
December 18, 2012 00:28
-
-
Save davidcelis/4323782 to your computer and use it in GitHub Desktop.
Output a Zelda-style heart meter for your MacBook's battery level. On the command line. Based on an idea from @stephencelis, executed by myself. For a tmux version, see https://gist.github.com/4324139
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# | |
# Works best with blinking text; the last heart will blink | |
# when you have less than 25% of your battery life remaining. | |
BATTERY="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')" | |
if [[ $BATTERY -lt 25 ]]; then | |
echo "\e[5;31m♥\e[0;31m♡♡\e[0m" | |
elif [[ $BATTERY -lt 50 ]]; then | |
echo "\e[31m♥♡♡\e[0m" | |
elif [[ $BATTERY -lt 75 ]]; then | |
echo "\e[31m♥♥♡\e[0m" | |
else | |
echo "\e[31m♥♥♥\e[0m" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case I have to look this up again, this is how I ended up doing it: