Skip to content

Instantly share code, notes, and snippets.

@source-c
Last active November 6, 2022 16:20
Show Gist options
  • Save source-c/c0e5e49cd27b9278626d6527e713ae02 to your computer and use it in GitHub Desktop.
Save source-c/c0e5e49cd27b9278626d6527e713ae02 to your computer and use it in GitHub Desktop.
Simple battery level fetch script for MacOS
#!/usr/bin/env bash
current_level=$(pmset -g batt|grep InternalBattery-0|sed -n 's#.*[[:space:]]\([[:digit:]]\{1,\}\)%.*#\1#p')
[[ -z ${current_level} ]] && current_level='--'
echo ${current_level}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment