Enables displaying battery percentage and status icon in tmux status-right.
Battery discharging, custom discharge icon:

This is done by introducing 3 new format strings that can be added to
status-right option:
#{battery_icon}- will display a battery status icon#{battery_percentage}- will show battery percentage#{battery_remain}- will show remaining time of battery charge
Add #{battery_icon}, #{battery_percentage} or #{battery_remain} format
strings to existing status-right tmux option. Example:
# in .tmux.conf
set -g status-right 'Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '
Installation with Tmux Plugin Manager (recommended)
Add plugin to the list of TPM plugins in .tmux.conf:
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-battery \
'
Hit prefix + I to fetch the plugin and source it.
If format strings are added to status-right, they should now be visible.
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-battery ~/clone/path
Add this line to the bottom of .tmux.conf:
run-shell ~/clone/path/battery.tmux
Reload TMUX environment:
# type this in terminal
$ tmux source-file ~/.tmux.conf
If format strings are added to status-right, they should now be visible.
By default, these icons are displayed:
- charged: ":battery:" ("❇ " when not on OS X)
- charging: ":zap:"
- discharging: (nothing shown)
- attached but not charging: ":warning:"
You can change these defaults by adding the following to .tmux.conf (the
following lines are not in the code block so that emojis can be seen):
- set -g @batt_charged_icon ":sunglasses:"
- set -g @batt_charging_icon ":+1:"
- set -g @batt_discharging_icon ":thumbsdown:"
- set -g @batt_attached_icon ":neutral_face:"
Don't forget to reload tmux environment ($ tmux source-file ~/.tmux.conf)
after you do this.
- Battery icon change most likely won't be instant.
When you un-plug power cord it will take some time (15 - 60 seconds) for the icon to change. This depends on thestatus-intervaltmux option. Setting it to 15 seconds should be good enough.
You might also find these useful:
- resurrect - restore tmux environment after system restart
- logging - easy logging and screen capturing
- online status - online status
indicator in tmux
status-right. Useful when on flaky connection to see if you're online.
You might want to follow @brunosutic on twitter if you want to hear about new tmux plugins or feature updates.


