Skip to content

Instantly share code, notes, and snippets.

@anmoljagetia
Forked from stephencelis/zelda-battery-tmux.sh
Last active September 8, 2015 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anmoljagetia/4777cbff2b3bc1fd980c to your computer and use it in GitHub Desktop.
Save anmoljagetia/4777cbff2b3bc1fd980c to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
#
# Works best with blinking text: the last heart will blink when you have less
# than 25% of your battery life remaining.
#
# Add the following to your `~/.tmux.conf`;
#
# set -g status-right "#[fg=red]#(path/to/zelda-battery-tmux.sh) "
battery="$(pmset -g ps | awk 'NR==2' | perl -pe 's/.*?(\d+)%.*/\1/')"
if [[ $battery -lt 25 ]]; then
echo "#[blink]♥#[noblink]♡♡"
elif [[ $battery -lt 50 ]]; then
echo "♥♡♡"
elif [[ $battery -lt 75 ]]; then
echo "♥♥♡"
else
echo "♥♥♥"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment