Battery is a bash script to display your Laptop's battery status on the terminal.
Latest commit f1bf779 Oct 23, 2016 @Goles committed on GitHub Merge pull request #30 from STJEREM/master
Add support for arch linux
Failed to load latest commit information.
.gitignore Added MIT License, fixes #13 Sep 10, 2013
LICENSE.txt Added MIT License, fixes #13 Sep 10, 2013 Update README Nov 5, 2015
battery Add support for arch linux Oct 21, 2016



Battery is a little bash script that uses Spark to display the battery status on your tmux sessions or the terminal.


  • Changes color to reflect battery status (Green, Yellow, Red)
  • Displays battery percentage
  • Graph bar changes its values between 0 and 100% (thanks to spark)
  • If you don't like the default colors, you can specify the good, medium and warning battery status colors using flags (read usage).


Right now, battery requires Spark to graph your battery status. Battery can run on both Mac OS X and Linux.

If you don't want to use Spark, you can use the -a flag, for ascii output: image

Install - Mac


Just do (case sensitive)

brew tap Goles/battery
brew install battery

One Liner

(Cut & Paste on terminal to install on /usr/bin, btw, try to run from ~/ or other writable dir)

brew install spark; curl -O ; \
sudo mv battery /usr/bin; sudo chmod 755 /usr/bin/battery

Step by Step

  • Install spark (with Homebrew on Mac OS X)

    brew install spark

  • Copy battery somewhere in your path & fix permissions

    sudo cp battery /usr/bin

    sudo chmod 755 /usr/bin/battery

Install - Linux

Linux support is still being tested. It ought to work properly in Debian and Ubuntu, but is largely untested in other distributions. Using linux requires upower, which should be included, or available, on most linux distributions.

It's recommended to install this somewhere in your path that is writable, like /usr/local/bin

# if you also want to use spark
curl -O
mv spark /usr/local/bin
chmod u+x /usr/local/bin/spark

curl -O
mv battery /usr/local/bin
chmod u+x /usr/local/bin/battery

NOTE: This spark is not the same spark that you would install by doing

$ sudo aptitude install spark

That is Apache Spark, which is a general engine for large-scale data processing.



  • Run Battery (From the terminal)


    You should see something like this:



  • Be sure to make tmux display utf-8 characters by running it with the -u flag

    tmux -u

  • Add the following line to your ~/.tmux.conf file

    set -g status-right "#(/usr/bin/battery -t)"

  • reload the tmux config by running tmux source-file ~/.tmux.conf.

You should now see something like this at the bottom right corner:



The flag -b will set a different battery path, the default value is /sys/class/power_supply/BAT0. You can specifiy the colors for good battery level, middle battery level, and warning battery level with the flags -g -m -w. Note: You should use color names for when in tmux mode and ascii colors in terminal mode. In Mac OS, you can specify to use pmset with the -p flag; without it, the program uses ioreg. In linux, this flag is ignored, and always uses upower.