Skip to content

Instantly share code, notes, and snippets.

@bylatt
Created October 24, 2015 17:45
Show Gist options
  • Select an option

  • Save bylatt/dede4e1fccff271bf2ff to your computer and use it in GitHub Desktop.

Select an option

Save bylatt/dede4e1fccff271bf2ff to your computer and use it in GitHub Desktop.
Show battery status on mac os x
#!/bin/bash
percent=$(pmset -g batt | egrep "([0-9]+\%).*" -o | cut -f1 -d'%')
args=("$@")
if [ "${args[0]}" == "debug" ]; then
echo "$percent"
fi
if [ "$percent" -gt "80" ]; then
result="★ ★ ★ ★ ★ "
elif [ "$percent" -gt "60" ]; then
result="★ ★ ★ ★ ☆ "
elif [ "$percent" -gt "40" ]; then
result="★ ★ ★ ☆ ☆ "
elif [ "$percent" -gt "20" ]; then
result="★ ★ ☆ ☆ ☆ "
elif [ "$percent" -gt "0" ]; then
result="★ ☆ ☆ ☆ ☆ "
fi
echo "$result"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment