Get Mac Battery Life from the Command Line in OS XGet Mac Battery Life from the Command Line in OS X

While most Mac laptop users will rely on the battery percentage indicator found in the menu bar of OS X, those who spend a lot of time at the command line may find it useful to know that MacBook battery life and battery charge percentage remaining information can be retrieved directly from the Terminal in Mac OS X.

This trick works to retrieve battery details on all Mac laptops in just about every version of OS X out there, whether it’s a MacBook Pro, MacBook Air, or MacBook.

Even if you aren’t a heavy command line user, this is a simple enough tip that anyone can get battery life info about their Mac this way, so just fire up the Terminal app and enter the appropriate pmset syntax.

How to View Battery Percentage, Battery Life Remaining, & Battery Charge Status of a Mac from the Command Line in OS X

The command to get battery information, including percentage, time remaining, battery source, and battery charge status, is as follows:

pmset -g batt

Getting Mac battery information from the command line in OS XGetting Mac battery information from the command line in OS X

Hit return as usual and you’ll see something like the following, assuming you’re currently running off a MacBook battery:

% pmset -g batt
Now drawing from 'Battery Power'
-InternalBattery-0 90%; discharging; 6:32 remaining

If the MacBook Pro / Air is connected to a MagSafe AC power adapter, the pmset command will report “AC Power” and display the status of the battery charging.

% pmset -g batt
Now drawing from 'AC Power'
-InternalBattery-0 100%; charged; 0:00 remaining

And if the MacBook is actively charging, you’ll also get information about current charge percentage and the time remaining until there is a full charge:

% pmset -g batt
Now drawing from 'AC Power'
-InternalBattery-0 92%; charging; 0:12 remaining

Of course if you use this command on a Mac that does not have an internal battery it won’t report anything, which is to be expected.

While the pmset command details specifics about the Macs internal battery, you can also get battery info about connected devices. Another helpful trick is to get Bluetooth device battery levels from the command line as well using a different command, which is great for users of a wireless keyboard and mouse.

The command line is generally geared towards more advanced users, and you can find the same type of information from the friendlier UI on the Mac through the battery menu bar and the Bluetooth menu bar too. If you notice your battery life is not performing as expected, you can find out what apps are using battery and energy and take action by either quitting them or ending the processes forcefully.

Source

Follow Me:
Top Best Sellers!!