Finding MacBook power status from command line (AC plugged in, or not)?
The pmset command has much shorter output than system_profiler:

pmset -g batt


The first line on my MacBook says "Now drawing from ..." either "AC Power"  or "Battery Power" when it runs.