jimeh / tmux-themepack

A pack of various Tmux themes.
1.68k stars 202 forks source link

Other plugins don't work with the custom themepack variables. #37

Closed jsatk closed 4 years ago

jsatk commented 4 years ago

I'm using https://github.com/tmux-plugins/tmux-cpu & https://github.com/tmux-plugins/tmux-battery. They work if I simply do:

set -g status-right "#{battery_icon} #{battery_percentage} #{cpu_icon} #{cpu_percentage}"

But if I try to use the customizable variables here it doesn't work:

set -goq @themepack-status-right-area-left-format "#{battery_icon} #{battery_percentage}"
set -goq @themepack-status-right-area-middle-format "#{cpu_icon} #{cpu_percentage}"

Any ideas on how to get this to work?

jsatk commented 4 years ago

After digging into man tmux it looks like putting F on the above variables should make them work but... it doesn't. 😞

jsatk commented 4 years ago

I was able to resolve this by changing the order in which things are called. I believe battery_icon wasn't ready yet when I was attempting to call it.

jimeh commented 4 years ago

@jsatk Oh, awesome, thanks for the update :)

I hadn’t had a chance to look into it yet, but I was worried there might be some incompatibility with how I implemented it, as I hadn’t tried those plugins myself yet.

jsatk commented 4 years ago

@jimeh nope. Totally my fault. It's complex stuff. 🤷‍♂ If you're super curious I chatted a bunch about this issue Wednesday night over on freenode's #tmux channel.

What ended up working is setting these variables after the plugins are loaded.

If you're really curious here's what's after I load the plugins via tpm and it all seems to work just fine.

# tmux-plugins/tmux-themepack {{{

set -g @themepack 'powerline/block/cyan'

# For some reason wttr.in is having trouble picking up my location, so
# hardcoding to San Francisco for now since I rarely ever use my computer
# outside of the city.
WEATHER='#(curl -s wttr.in/SanFrancisco\?format\="%%c+%%t")'
NOW_PLAYING='#(~/Library/scripts/now-playing-with-song-title.js)'
set -goq @themepack-status-left-area-left-format "#S"
set -goq @themepack-status-left-area-middle-format "" # TODO: Figure out what to put in here.
set -goq @themepack-status-left-area-right-format "#I:#P"
set -goq @themepack-status-right-area-left-prefix "#{prefix_highlight}"
# The tmux-battery plugin sets the background to black.  This uses the
# tmux-themepack variables and sets the `fg` & `bg` to what's in the theme.
set -goq @themepack-status-right-area-left-format "#[fg=#{@powerline-status-right-area-left-fg}, bg=#{@powerline-status-right-area-left-bg}] #{battery_icon} #{battery_percentage}"
set -goq @themepack-status-right-area-middle-format "#{cpu_icon} #{cpu_percentage}"
set -goq @themepack-status-right-area-right-format "%a %h-%d %H:%M $WEATHER $NOW_PLAYING"

# }}}