catppuccin / tmux

πŸ’½ Soothing pastel theme for Tmux
MIT License
1.95k stars 615 forks source link

Weather module not working #345

Closed jeffcap1 closed 1 month ago

jeffcap1 commented 1 month ago

Is there an existing issue outlining your problem?

Describe your problem.

The weather module does not appear to be working after upgrading to v1.0.0. On v0.3.0 I was using tmux-weather. After I upgraded to v1.0.0 I noticed the weather module stopped working and thought it might have been an issue with tmux-weather so I switched to tmux-clima, however, I'm seeing the same issue with that module as well.

Paste your configuration.

# new leader key
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix

# fix colors
set -g default-terminal 'tmux-256color'
set -ga terminal-overrides ",xterm-256color*:Tc"

# cursor
# Force cursor shape as blinking bar (xterm)
# https://neovim.io/doc/user/term.html#tui-cursor-shape
set -as terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[5 q'

# refresh tmux with leader + r
unbind r
bind r command-prompt "rename-window %%"
bind R source ~/.config/tmux/tmux.conf

# splits and navigation
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind -n M-H previous-window
bind -n M-L next-window
bind-key x kill-pane # skip "kill-pane 1? (y/n)" prompt

# Start windows and panes at 1, not 0
set -g base-index 1                  # start indexing windows at 1 instead of 0
set -g pane-base-index 1             # start indexing panes at 1 instead of 0
set-window-option -g pane-base-index 1
set -g renumber-windows on           # renumber all windows when any window is closed

# options
set -g mouse on                      # mouse support
set -g detach-on-destroy off         # don't exit from tmux when closing a session
set -g escape-time 0                 # zero-out escape time delay
set -g history-limit 1000000         # increase history size (from 2,000)
set -g set-clipboard on              # use system clipboard

# status bar
set -g status-justify left
set -g status-left-length 200
set -g status-right-length 200
set -g status-position top

# set vi mode
set -g xterm-keys on
set -g mode-keys vi
set -g status-keys vi

# act like vim
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-l select-pane -R

# copy mode
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi C-v send -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel

# keybinding fixes
bind k send-keys -R \; clear-history

# Sesh keybinding
bind-key "T" clock-mode
unbind t
bind-key "t" run-shell "sesh connect \"$(
  sesh list | fzf-tmux -p 55%,60% \
    --no-sort --border-label ' sesh ' --prompt '⚑  ' \
    --header '  ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
    --bind 'tab:down,btab:up' \
    --bind 'ctrl-a:change-prompt(⚑  )+reload(sesh list)' \
    --bind 'ctrl-t:change-prompt(πŸͺŸ  )+reload(sesh list -t)' \
    --bind 'ctrl-g:change-prompt(βš™οΈ  )+reload(sesh list -c)' \
    --bind 'ctrl-x:change-prompt(πŸ“  )+reload(sesh list -z)' \
    --bind 'ctrl-f:change-prompt(πŸ”Ž  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
    --bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚑  )+reload(sesh list)'
)\""

set -g @continuum-save-interval '5'
# set -g @continuum-restore 'on'

# resurrect strategy
set -g @resurrect-strategy-nvim 'session'

# tmux-naviagtor remap
set -g @vim_navigator_mapping_left "M-h"
set -g @vim_navigator_mapping_right "M-l"
set -g @vim_navigator_mapping_up "M-k"
set -g @vim_navigator_mapping_down "M-j"

# theme flavor
set -g @catppuccin_flavor "macchiato"

# status format
set -g @catppuccin_status_default "on"
set -g @catppuccin_status_background "none"
set -g @catppuccin_status_connect_separator "no"

# window icons
set -g @catppuccin_icon_window_last "σ°–° "
set -g @catppuccin_icon_window_current "σ°–― "
set -g @catppuccin_icon_window_zoom "󰁌 "
set -g @catppuccin_icon_window_mark "󰃀 "
set -g @catppuccin_icon_window_silent "σ°‚› "
set -g @catppuccin_icon_window_activity "σ±…« "
set -g @catppuccin_icon_window_bell "σ°‚ž "

# window format
set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_status "icon"

# window default format
set -g @catppuccin_window_default_fill "none"
set -g @catppuccin_window_default_text "#W"

# window current format
set -g @catppuccin_window_current_fill "all"
set -g @catppuccin_window_current_text "#W"

# status format
set -g @catppuccin_status_left_separator  "ξ‚Ά"
set -g @catppuccin_status_right_separator "ξ‚΄ "
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"

# directory format
set -g @catppuccin_directory_text "#{b:pane_current_path}"

# date format
set -g @catppuccin_date_time_text "%H:%M"

# weather format
# set-option -g @tmux-weather-location "Wayne,%20NJ"
# set-option -g @tmux-weather-format "%l:+%t+%c"
# set-option -g @tmux-weather-units "u"

set -g @clima_unit imperial
set -g @clima_location "Wayne, NJ"
# set -g @clima_show_location 0 # hide location
# set -g @clima_ttl <value_in_minutes>
# set -g @clima_use_nerd_font 1

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -ag status-right "#{E:@catppuccin_status_clima}"
# set -ag status-right "#{E:@catppuccin_status_weather}"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

set -g @plugin 'catppuccin/tmux'
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Attach screenshots.

image

What tmux version are you seeing the issue on?

tmux 3.5

Any additional comments?

No response

jakub-hajek commented 1 month ago

dirty workaround is to change clima.conf: set -ogq "@catppuccin_${MODULE_NAME}_text" "#(~/.config/tmux/plugins/tmux-clima/scripts/clima.sh)"

jeffcap1 commented 1 month ago

@jakub-hajek, thanks for your comment. If I run ~/.config/tmux/plugins/tmux-clima/scripts/clima.sh in my terminal I receive the weather data as expected which is great.

Unfortunately, when I added that line to my tmux config I did not see the text appear in the clima status module. I also tried updating your suggestion to set -ogq "@catppuccin_status_clima_text" "#(~/.config/tmux/plugins/tmux-clima/scripts/clima.sh)" but that did not work either.

jeffcap1 commented 1 month ago

I just updated to the latest version, and I can confirm the documented fix does work.

Unfortunately, adding the -F flag, which is required to print the text, has the side effect of making the plugin not show until the tmux config is reloaded. This is similar to a previous issue, 337.

Status Config

set -g @clima_unit imperial
set -g @clima_show_location 0 # hide location
set -g @clima_use_nerd_font 1

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"

Tmux startup

image

After reloading Tmux

image

Removing -F flag, shows up right away but with placeholder

image
kjnsn commented 1 month ago

This is working as intended. You need to import catppuccin before the weather module. If this is not clear from the documentation, could you please send a PR making it more obvious?

jeffcap1 commented 1 month ago

Sorry, that must have been an RTFM fail on my part. I updated my config to load catppuccin first and then the clima plugin as stated in the docs. Unfortunately, I am still seeing the issue where the clima module does not load unless I refresh the config. Here are my updated settings for catppuccin and how I'm loading code through TPM.

...

# theme flavor
set -g @catppuccin_flavor "macchiato"

# status format
set -g @catppuccin_status_default "on"
set -g @catppuccin_status_background "none"
set -g @catppuccin_status_connect_separator "no"

# window icons
set -g @catppuccin_icon_window_last "σ°–° "
set -g @catppuccin_icon_window_current "σ°–― "
set -g @catppuccin_icon_window_zoom "󰁌 "
set -g @catppuccin_icon_window_mark "󰃀 "
set -g @catppuccin_icon_window_silent "σ°‚› "
set -g @catppuccin_icon_window_activity "σ±…« "
set -g @catppuccin_icon_window_bell "σ°‚ž "

# window format
set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_status "icon"

# window default format
set -g @catppuccin_window_default_fill "none"
set -g @catppuccin_window_default_text "#W"

# window current format
set -g @catppuccin_window_current_fill "all"
set -g @catppuccin_window_current_text "#W"

# status format
set -g @catppuccin_status_left_separator  "ξ‚Ά"
set -g @catppuccin_status_right_separator "ξ‚΄ "
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"

# directory format
set -g @catppuccin_directory_text "#{b:pane_current_path}"

# date format
set -g @catppuccin_date_time_text "%H:%M"

# weather format
set -g @clima_unit imperial
set -g @clima_show_location 0 # hide location
set -g @clima_use_nerd_font 1

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

# Load catppuccin plugins after
set -g @plugin 'vascomfnunes/tmux-clima'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
davidfmatheson commented 1 month ago

I've been trying to understand the order of operations for the battery plugin in issue #342. My dotfile rewrite efforts are here. If you just set status-right with -g it will leave it as #{E:@catppuccin_status_clima} and you'll get the placeholder as it expands when you run tpm at the bottom (I think?), but if you run it with -gF it tries to expand "#{E:@catppuccin_status_clima}" at that point and because that's not defined yet it expands to blank. That's why we're being told to import catppuccin, then set status-right (so the variable is defined), then import weather/battery, so adding

run "~/.config/tmux/plugins/tmux/catppuccin.tmux"

(or wherever that file lives for you) before you do your set -agF status-right might help you out, but that's not going to be there if you run a clean_plugins or start on a new machine, so you may have to reload the config in that case.

kjnsn commented 1 month ago

TPM does not do any expanding? Not sure where that conclusion came from.

You are correct that @catppuccin_status_clima is not defined until catppuccin loads. The clima plugin isn't that complicated, it's literally a string replacement.

I would appreciate a PR with documentation updates

jeffcap1 commented 1 month ago

I'd be happy to provide a PR with updates to the documentation once I can get this working, but as it is right now, this is still not working as expected in my setup. On v0.3.0 the weather/clima plugin would load on tmux start, but in v1.x I cannot seem to get that to work unless I refresh the config.

I've also tried moving where I load catppuccin and clima to before I set my status left and right modules, and also moved everything to after I run tpm, but neither change has seemed to do what I expect.

Loading status modules after defining TPM

Same issue, it does not show until I refresh my config

...
### >>>>> DEFINE TPM AND PLUIGINS FIRST

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

# Load catppuccin plugins after
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

### >>>>> NOW DEFINE MODULES

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"
# set -ag status-right "#{E:@catppuccin_status_weather}"

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Loading status modules after TPM run

Clima module shows, but is blank. Upon refresh it flashes the information and then becomes blank again.

image
...
# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

# Load catppuccin plugins after
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

### >>>>> LOAD MODULES AFTER RUNNING TPM

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"
# set -ag status-right "#{E:@catppuccin_status_weather}"
kjnsn commented 1 month ago

Yeah neither of those will work. You need to run clima after the status-right is set

kjnsn commented 1 month ago

Clima works by inspecting the status right option, and replacing a string in it. Here's the equivalent concept of string replacement for javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

Clima does the same thing with sed

jeffcap1 commented 1 month ago

Hmm, I just updated my config to the below, which I believe is what you suggested, but I am getting the same result. Not quite sure what I am doing wrong haha.

### >>>> Status modules except clima

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

### >>>> Load Catppuccin theme

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

### >>>> Define clima status module and then load it immediately after

# Load catppuccin plugins after
set -agF status-right "#{E:@catppuccin_status_clima}"
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
kjnsn commented 1 month ago

Where are you loading catppuccin before running tpm?

jeffcap1 commented 1 month ago

In that last example, TPM is set/loaded, then catppuccin is being loaded right before I am setting and running the clima plugin. At the end of the file TPM is actually run.

kjnsn commented 1 month ago

set -g @plugin actually does nothing. It's a string that is searched for by the TPM script. You aren't loading anything until you use run.

There's no magic here, set just sets an option. It's not loading anything.

jeffcap1 commented 1 month ago

That all makes sense to me. Options are being set in the config and then executed when using the tpm run command.

I guess I am misunderstanding your question then about loading catppuccin. I set the plugin before I run tpm, but is there something else I should be doing to load catppuccin?

Would you mind correcting the snippet I provided so it is running in the correct order as you would expect it? I can then update my config to see if that fixes the issue on my end.

### >>>> Status modules except clima

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

### >>>> Load Catppuccin theme

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

### >>>> Define clima status module and then load it immediately after

# Load catppuccin plugins after
set -agF status-right "#{E:@catppuccin_status_clima}"
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Surgo commented 1 month ago

@jeffcap1 I think the expected order is following.

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'vascomfnunes/tmux-clima'

run '~/.tmux/plugins/tpm/tpm'

set -g status-left "#{E:@catppuccin_status_session}"

set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"

However, this doesn’t work well in my environment either...

kjnsn commented 1 month ago

That's wrong as well... Like I have said, twice

run '~/.tmux/plugins/tpm/tpm'

set -g status-left "#{E:@catppuccin_status_session}"

set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"

run '~/.tmux/plugins/tpm/tpm'

# Surprise, it doesn't matter where these go. They do nothing except give instructions to TPM
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'vascomfnunes/tmux-clima'

@catppuccin_status_clima is a global option. If you haven't run catppuccin yet, why would it be defined?

Additionally, if status-right isn't set, then why would the clima plugin work?

jeffcap1 commented 1 month ago

I got it working, but it needed to be run 3 times.

run '~/.tmux/plugins/tpm/tpm'

# modules list
## left
set -g status-left "#{E:@catppuccin_status_session}"

## right
set -g status-right "#{E:@catppuccin_status_application}"
set -ag status-right "#{E:@catppuccin_status_directory}"
set -ag status-right "#{E:@catppuccin_status_date_time}"
set -agF status-right "#{E:@catppuccin_status_clima}"
# set -ag status-right "#{E:@catppuccin_status_weather}"

run '~/.tmux/plugins/tpm/tpm'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'jimeh/tmuxifier'

# Load catppuccin theme first
set -g @plugin 'catppuccin/tmux'

# Load catppuccin plugins after
set -g @plugin 'vascomfnunes/tmux-clima'
# set -g @plugin 'xamut/tmux-weather'

# Fixes plugin being overwritten by theme
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
jeffcap1 commented 1 month ago

Thank you @kjnsn for all of your support on this.