Skip to content

Plug and play battery percentage and icon indicator for Tmux.

License

Notifications You must be signed in to change notification settings

jgeralnik/tmux-battery-osx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tmux battery status for OSX

Enables displaying battery percentage and status icon in Tmux status-right.

Battery full:
battery full

Battery discharging, custom discharge icon:
battery discharging, custom icon

Battery charging:
battery charging

This is done by introducing 2 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

Usage

Add #{battery_icon} or #{battery_percentage} format strings to existing status-right Tmux option. Example:

# in .tmux.conf
set -g status-right "Batt: #{battery_icon} #{battery_percentage} | %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-osx       \
"

Hit prefix + I to fetch the plugin and source it.

If format strings are added to status-right, they should now be visible.

Manual Installation

Clone the repo:

$ git clone https://github.com/tmux-plugins/tmux-battery-osx ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/battery_osx.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.

Changing icons

By default, these icons are displayed:

  • charged: ":battery:"
  • charging: ":zap:"
  • discharging: (nothing shown)

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-option -g @batt_charged_icon ":sunglasses:"
  • set-option -g @batt_charging_icon ":+1:"
  • set-option -g @batt_discharging_icon ":thumbsdown:"

Reminder: OSX allows you to insert various emojis by pressing Cmd+Ctrl+Space.

Don't forget to reload TMUX environment ($ tmux source-file ~/.tmux.conf) after you do this.

Known issues

  • Battery icon change most likely won't be instant.
    For example, when you un-plug power cord it will take some time (15 - 60 seconds) for the icon to change. This depends on the status-interval TMUX option. Setting it to 15 seconds should be good enough.

Other plugins

You might also find these useful:

  • 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.

License

MIT

About

Plug and play battery percentage and icon indicator for Tmux.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%