tmux-plugins / tmux-battery

Plug and play battery percentage and icon indicator for Tmux.
MIT License
503 stars 98 forks source link

Support for custom background colors #74

Closed ricvillagrana closed 5 years ago

ricvillagrana commented 5 years ago

I am facing a problem with background color and my font color, I would need to edit plugin colors to be easy to read. I know I can set the color to {battery_status_fg} but, It would be cool, add your custom colors 😎 screenshot from 2019-01-25 09-35-13

rux616 commented 5 years ago

If I'm understanding you correctly, you're wanting to make sure the foreground color is still readable where you have the background color representing the battery status. There are two ways I can think of to do that.

Method 1

The first way is to manually specify a foreground color in your status line definition. Taking an approximation of the status line you have,

'#{battery_status_bg} Batt: #{battery_icon}#{battery_percentage} #{battery_remain} | (...)'

can be changed to something like

'#{battery_status_bg}#[fg=colour0] Batt: #{battery_icon}#{battery_percentage} #{battery_remain} | (...)'

The drawback of this method is that you're stuck trying to defining a single foreground color that works with all battery status colors.

Method 2

Alternatively, you can specify whatever foreground you want right in the set -g @batt_color_... declarations in your .tmux.conf file, like so:

set -g @batt_color_full_charge '#[bg=green,fg=black]'
set -g @batt_color_high_charge '#[bg=yellow,fg=black]'
set -g @batt_color_medium_charge '#[bg=colour208,fg=black]'
set -g @batt_color_low_charge '#[bg=red,fg=white]'
set -g @batt_color_charging '#[bg=green,fg=black]'

then change your status line to

'#{battery_status_bg} Batt: #{battery_icon}#{battery_percentage} #{battery_remain} #[bg=black,fg=green]| (...)'

to reset the colors after the battery section in the status line.

ricvillagrana commented 5 years ago

Yes, this is what I was looking for. Thank you!