• Stars
    star
    499
  • Rank 88,341 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 10 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plug and play battery percentage and icon indicator for Tmux.

Tmux battery status

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

Installation

In order to read the battery status, this plugin depends on having one of the following applications installed:

  • pmset (MacOS only)
  • acpi
  • upower
  • termux-battery-status
  • apm

In a normal situation, one of the above should be installed on your system by default and thus it should not be necessary to specifically install one of them. That being said, the acpi utility is currently recommended for use over upower where possible due to ongoing CPU usage issues.

Installation with Tmux Plugin Manager (recommended)

Add plugin to the list of TPM plugins in .tmux.conf:

set -g @plugin '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.

Manual Installation

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

From the terminal, reload TMUX environment:

tmux source-file ~/.tmux.conf

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

Usage

Add any of the supported format strings (see below) to the status-right tmux option in .tmux.conf. Example:

set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '

Supported Format Strings

  • #{battery_color_bg} - will set the background color of the status bar based on the battery charge level if discharging and status otherwise
  • #{battery_color_fg} - will set the foreground color of the status bar based on the battery charge level if discharging and status otherwise
  • #{battery_color_charge_bg} - will set the background color of the status bar based solely on the battery charge level
  • #{battery_color_charge_fg} - will set the foreground color of the status bar based solely on the battery charge level
  • #{battery_color_status_bg} - will set the background color of the status bar based solely on the battery status
  • #{battery_color_status_fg} - will set the foreground color of the status bar based solely on the battery status
  • #{battery_graph} - will show battery percentage as a bar graph: ▁▂▄▆█
  • #{battery_icon} - will display a battery status/charge icon
  • #{battery_icon_charge} - will display a battery charge icon
  • #{battery_icon_status} - will display a battery status icon
  • #{battery_percentage} - will show battery percentage
  • #{battery_remain} - will show remaining time of battery charge*

* These format strings can be further customized via options as described below.

Options

#{battery_remain}

  • @batt_remain_short: 'true' / 'false' - This will shorten the time remaining (when charging or discharging) to ~H:MM.

Defaults

Options

  • @batt_remain_short: 'false'

Icons/Colors

By default, the following colors and icons are used. (The exact colors displayed depends on your terminal / X11 config.)

Please be aware that the 'level of charge' as noted below (e.g. [80%-95%)) uses interval notation. If you are unfamiliar with it, check it out here.

Also, a note about the @batt_color_... options: @batt_color_..._primary_... options are what will be displayed in the main bg or fg format strings you choose - e.g. if you use #{battery_color_bg}, the @batt_color_..._primary_... colors you choose will be the background. Likewise, the corresponding @batt_color_..._secondary_... color will be the foreground.

Level of Charge Colors:

  • primary tier 8 [95%-100%] (@batt_color_charge_primary_tier8): '#00ff00'
  • primary tier 7 [80%-95%) (@batt_color_charge_primary_tier7): '#55ff00'
  • primary tier 6 [65%-80%) (@batt_color_charge_primary_tier6): '#aaff00'
  • primary tier 5 [50%-65%) (@batt_color_charge_primary_tier5): '#ffff00'
  • primary tier 4 [35%-50%) (@batt_color_charge_primary_tier4): '#ffc000'
  • primary tier 3 [20%-35%) (@batt_color_charge_primary_tier3): '#ff8000'
  • primary tier 2 (5%-20%) (@batt_color_charge_primary_tier2): '#ff4000'
  • primary tier 1 [0%-5%] (@batt_color_charge_primary_tier1): '#ff0000'
  • secondary tier 8 [95%-100%] (@batt_color_charge_secondary_tier8): 'colour0'
  • secondary tier 7 [80%-95%) (@batt_color_charge_secondary_tier7): 'colour0'
  • secondary tier 6 [65%-80%) (@batt_color_charge_secondary_tier6): 'colour0'
  • secondary tier 5 [50%-65%) (@batt_color_charge_secondary_tier5): 'colour0'
  • secondary tier 4 [35%-50%) (@batt_color_charge_secondary_tier4): 'colour0'
  • secondary tier 3 [20%-35%) (@batt_color_charge_secondary_tier3): 'colour0'
  • secondary tier 2 (5%-20%) (@batt_color_charge_secondary_tier2): 'colour0'
  • secondary tier 1 [0%-5%] (@batt_color_charge_secondary_tier1): 'colour0'

Status Colors:

  • primary charged (@batt_color_status_primary_charged): 'colour33'
  • primary charging (@batt_color_status_primary_charging): 'colour33'
  • primary discharging (@batt_color_status_primary_discharging): 'colour14'
  • primary attached (@batt_color_status_primary_attached): 'colour201'
  • primary unknown (@batt_color_status_primary_unknown): 'colour7'
  • secondary charged (@batt_color_status_secondary_charged): 'colour0'
  • secondary charging (@batt_color_status_secondary_charging): 'colour0'
  • secondary discharging (@batt_color_status_secondary_discharging): 'colour0'
  • secondary attached (@batt_color_status_secondary_attached): 'colour0'
  • secondary unknown (@batt_color_status_secondary_unknown): 'colour0'

Level of Charge Icons:

  • tier 8 [95%-100%] (@batt_icon_charge_tier8): '█'
  • tier 7 [80%-95%) (@batt_icon_charge_tier7): '▇'
  • tier 6 [65%-80%) (@batt_icon_charge_tier6): '▆'
  • tier 5 [50%-65%) (@batt_icon_charge_tier5): '▅'
  • tier 4 [35%-50%) (@batt_icon_charge_tier4): '▄'
  • tier 3 [20%-35%) (@batt_icon_charge_tier3): '▃'
  • tier 2 (5%-20%) (@batt_icon_charge_tier2): '▂'
  • tier 1 [0%-5%] (@batt_icon_charge_tier1): '▁'

Status Icons:

  • charged (@batt_icon_status_charged): '🔌'
  • charged - OS X (@batt_icon_status_charged): '🔌'
  • charging (@batt_icon_status_charging): '🔌'
  • discharging (@batt_icon_status_discharging): '🔋'
  • attached (@batt_icon_status_attached): '⚠️'
  • unknown (@batt_icon_status_unknown): '?'

Changing the Defaults

All efforts have been made to make sane defaults, but if you wish to change any of them, add the option to .tmux.conf. For example:

set -g @batt_icon_charge_tier8 '🌕'
set -g @batt_icon_charge_tier7 '🌖'
set -g @batt_icon_charge_tier6 '🌖'
set -g @batt_icon_charge_tier5 '🌗'
set -g @batt_icon_charge_tier4 '🌗'
set -g @batt_icon_charge_tier3 '🌘'
set -g @batt_icon_charge_tier2 '🌘'
set -g @batt_icon_charge_tier1 '🌑'
set -g @batt_icon_status_charged '🔋'
set -g @batt_icon_status_charging ''
set -g @batt_icon_status_discharging '👎'
set -g @batt_color_status_primary_charged '#3daee9'
set -g @batt_color_status_primary_charging '#3daee9'

Don't forget to reload the tmux environment after you do this by either hitting <prefix> + I if tmux battery is installed via the tmux plugin manager, or by typing tmux source-file ~/.tmux.conf in the terminal if tmux battery is manually installed.

Warning: The battery icon change most likely will not be instant. When you un-plug the 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.

Examples

These are all examples of the default plugin color and icon schemes paired with the default tmux color scheme using the following status-right and status-right-length settings in .tmux.conf

set -g status-right 'Colors: #{battery_color_bg}bg#[default] #{battery_color_fg}fg#[default] #{battery_color_charge_bg}charge_bg#[default] #{battery_color_charge_fg}charge_fg#[default] #{battery_color_status_bg}status_bg#[default] #{battery_color_status_fg}status_fg#[default] | Graph: #{battery_graph} | Icon: #{battery_icon} | Charge Icon: #{battery_icon_charge} | Status Icon: #{battery_icon_status} | Percent: #{battery_percentage} | Remain: #{battery_remain}'
set -g status-right-length '150'

Battery charging at tier 8 [95%-100%]:
battery-charging-tier8

Battery charging at tier 7 [80%-95%):
battery-charging-tier7

Battery charging at tier 6 [65%-80%):
battery-charging-tier6

Battery charging at tier 5 [50%-65%):
battery-charging-tier5

Battery charging at tier 4 [35%-50%):
battery-charging-tier4

Battery charging at tier 3 [20%-35%):
battery-charging-tier3

Battery charging at tier 2 (5%-20%):
battery-charging-tier2

Battery charging at tier 1 [0%-5%]:
battery-charging-tier1

Battery discharging at tier 8 [95%-100%]:
battery-discharging-tier8

Battery discharging at tier 7 [80%-95%):
battery-discharging-tier7

Battery discharging at tier 6 [65%-80%):
battery-discharging-tier6

Battery discharging at tier 5 [50%-65%):
battery-discharging-tier5

Battery discharging at tier 4 [35%-50%):
battery-discharging-tier4

Battery discharging at tier 3 [20%-35%):
battery-discharging-tier3

Battery discharging at tier 2 (5%-20%):
battery-discharging-tier2

Battery discharging at tier 1 [0%-5%]:
battery-discharging-tier1

Battery in 'attached' status:
battery-status-attached

Battery in an unknown status:
battery-status-unknown

Tmux Plugins

This plugin is part of the tmux-plugins organisation. Checkout plugins as resurrect, logging, online status, and many more over at the tmux-plugins organisation page.

Maintainer

Contributors

  • Adam Biggs
  • Aleksandar Djurdjic
  • Bruno Sutic
  • Caleb
  • Dan Cassidy
  • Diego Ximenes
  • Evan N-D
  • Jan Ahrens
  • Joey Geralnik
  • HyunJong (Joseph) Lee
  • Martin Beentjes
  • Mike Foley
  • Ryan Frantz
  • Seth Wright
  • Tom Levens

License

MIT

More Repositories

1

tpm

Tmux Plugin Manager
Shell
12,082
star
2

tmux-resurrect

Persists tmux environment across system restarts.
Shell
11,249
star
3

tmux-continuum

Continuous saving of tmux environment. Automatic restore when tmux is started. Automatic tmux start when computer is turned on.
Shell
3,263
star
4

tmux-yank

Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.
Shell
2,682
star
5

tmux-sensible

basic tmux settings everyone can agree on
Shell
1,756
star
6

list

A list of tmux plugins.
1,201
star
7

tmux-copycat

A plugin that enhances tmux search
Shell
1,103
star
8

tmux-logging

Easy logging and screen capturing for Tmux.
Shell
1,034
star
9

tmux-pain-control

standard pane key-bindings for tmux
Shell
755
star
10

tmux-open

Tmux key bindings for quick opening of a highlighted file or url
Shell
631
star
11

tmux-prefix-highlight

Plugin that highlights when you press tmux prefix key
Shell
571
star
12

tmux-sidebar

A sidebar with the directory tree for the current path. Tries to make tmux more IDE like.
Shell
536
star
13

tmux-cpu

Plug and play cpu percentage and icon indicator for Tmux.
Shell
433
star
14

tmux-sessionist

Lightweight tmux utils for manipulating sessions
Shell
412
star
15

vim-tmux-focus-events

Make terminal vim and tmux work better together.
Vim Script
348
star
16

vim-tmux

vim plugin for tmux.conf
Vim Script
333
star
17

tmux-fpp

Quickly open any path on your terminal window in your $EDITOR of choice!
Shell
308
star
18

tmux-urlview

Quickly open any url on your terminal window!
Shell
266
star
19

tmux-online-status

Tmux plugin that displays online status of your computer.
Shell
169
star
20

tmux-example-plugin

Example Tmux plugin that actually demonstrates how to build plugins for Tmux. The accompanying tutorial is here: https://github.com/tmux-plugins/tpm/blob/master/HOW_TO_PLUGIN.md
Shell
45
star
21

tmux-cowboy

Kill hanging processes fast
Shell
37
star
22

tmux-maildir-counter

Plugin that counts files on a specific mail directory
Shell
32
star
23

tmux-test

A small framework for isolated testing of tmux plugins.
Shell
16
star
24

language-tmux

Atom language support for Tmux config file
CoffeeScript
10
star
25

tmux-newsboat

Display newsboat counters in tmux status line.
Shell
10
star