tmux-plugins / tmux-battery

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

Battery metrics flash then disappear #15

Closed adamgibbins closed 9 years ago

adamgibbins commented 9 years ago

Hi, I've got a weird bug, I load the plugin, configure it in my status-right - hit reload - battery icon + percentage appears, then .5s later - disappears, never to be seen again. I reload, same thing happens. Restarting tmux, brand new session doesn't fix. Nor does emptying my config of everything but the status-right + TPM.

Every seen this before? How can I fix it, or even debug?

Thanks

bruno- commented 9 years ago

That's unusual, never had this one. Care to link or paste the content of your .tmux.conf?

Also, what is the output of tmux show -g status-right?

adamgibbins commented 9 years ago

So I can reproduce with an absolute bare minimum tmux.conf:

set -g @tpm_plugins "              \
  tmux-plugins/tmux-battery        \
"

run-shell ~/.tmux/plugins/tpm/tpm
set-option -g status-right "#[fg=yellow][ #{battery_percentage} #{battery_remain}] [ %a %d-%h %H:%M ]"

If I run :show -g status-right it outputs: status-right "#[fg=yellow][ #{battery_percentage} #{battery_remain}] [ %a %d-%h %H:%M ]"

I'm running tmux 2.0 under Terminal in Yosemite (although I use iTerm2 day to day, where its also reproducible).

bruno- commented 9 years ago

Hey, the above won't work .. run-shell ~/.tmux/plugins/tpm/tpm line should be the absolute last line in .tmux.conf.

Try setting status-right first, and leaving plugin definition and initialization last:

set-option -g status-right "#[fg=yellow][ #{battery_percentage} #{battery_remain}] [ %a %d-%h %H:%M ]"

set -g @tpm_plugins "              \
  tmux-plugins/tmux-battery        \
"
run-shell ~/.tmux/plugins/tpm/tpm
adamgibbins commented 9 years ago

Huh, that has indeed fixed - thanks! I find that very odd, I'd presume the tmux config was sequential and that you couldn't use plugins until they were defined. Oh well, lesson learnt - thanks again!