Skip to content

Instantly share code, notes, and snippets.

@tylerkerr
Created December 23, 2018 05:40
Show Gist options
  • Save tylerkerr/d6ab77621cf8e790563cdd702b17e75e to your computer and use it in GitHub Desktop.
Save tylerkerr/d6ab77621cf8e790563cdd702b17e75e to your computer and use it in GitHub Desktop.
function battime()
{
minutes=$(/usr/sbin/ioreg -r -n AppleSmartBattery | grep InstantTimeToEmpty | \grep -Eo "\d+")
hours=$(echo "$minutes / 60" | bc)
remainder=$(echo "$minutes - (60 * $hours)" | bc)
echo "[+] battery time remaining : ${hours}h ${remainder}m"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment