catppuccin / tmux

💽 Soothing pastel theme for Tmux
MIT License
1.92k stars 605 forks source link

Kube module keeps going blank #301

Closed pauldthomson closed 2 months ago

pauldthomson commented 2 months ago

Is there an existing issue outlining your problem?

Describe your problem.

The kube module stops showing anything and I have to reload my tmux conf to make it appear again

Paste your configuration.

set -g default-terminal 'tmux-256color'
# set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'

# Workaround for tmux + system clipbaord on MacOS
if-shell "[ type reattach-to-user-namespace ]" \
    "set-option -g default-command \"reattach-to-user-namespace -l bash\""

set-window-option -g mode-keys vi

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

# Prompt for window title when creating new window
bind-key c command-prompt -p "Name of new window: " "new-window -n '%%'"

# Send prefix to nested tmux sessions
bind-key a send-prefix

# Disable delay between escape key and subsequent keys in vim
set -sg escape-time 0

# Start window numbering at 1
set -g base-index 1

# Automatically renumber windows if one is closed
set -g renumber-windows on

# Start pane numbering at 1
setw -g pane-base-index 1

# Scroll history
set -g history-limit 3000

# Enable mouse scrolling
setw -g mouse on

# Stay in copy mode on drag end.
unbind-key -T copy-mode-vi MouseDragEnd1Pane

# Pane resizing with PREFIX + Alt-hjkl
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# Set prefix to space.
unbind-key C-b
set-option -g prefix C-Space

# Split pane horizontally with PREFIX + -
bind - split-window -v -c '#{pane_current_path}'

# Split pane vertically with PREFIX + |
bind | split-window -h -c '#{pane_current_path}'

# Use vim style keys
set -g status-keys vi
setw -g mode-keys vi

# Reload .tmux.conf with PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h"  "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j"  "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l"  "select-pane -R"
# bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
# bind-key -T copy-mode-vi C-\ select-pane -l

# Use <prefix> C-l to clear screen
bind C-l send-keys "C-l"

# Copy to system clipboard
bind -T copy-mode-vi 'v' send-keys -X begin-selection
bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel "pbcopy"

# Interactive search of windows/sessions
bind j split-window -v "tmux list-sessions -F '#S' | fzf --reverse | xargs tmux switch-client -t"
bind k split-window -v "tmux list-window -F '#W' | fzf --reverse | xargs tmux select-window -t"

# Plugins
set -g @plugin 'catppuccin/tmux#latest'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'jonmosco/kube-tmux'

set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator " "
set -g @catppuccin_window_middle_separator " █"
set -g @catppuccin_window_number_position "right"

set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_default_text "#W"

set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_current_text "#W"

set -g @catppuccin_status_modules_right "session kube"
set -g @catppuccin_status_left_separator  " "
set -g @catppuccin_status_right_separator ""
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_status_connect_separator "no"

set -g @catppuccin_directory_text "#{pane_current_path}"

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

Attach screenshots.

https://github.com/user-attachments/assets/1c57c642-0f59-4240-b27a-d905174f2026

What tmux version are you seeing the issue on?

tmux 3.4

Any additional comments?

I have been running kube-tmux for a long time prior to using catppuccin and this issue didn't exist, so it seems theme related?

vdbe commented 2 months ago

Can you show the output of tmux show-options -g status-right when starting tmux and after reloading it once?

It seems that the env TMUX_PLUGIN_MANAGER_PATH is empty here when using ~/.tmux.conf instead of ~/.config/tmux/tmux.conf but not for the shell (and subsequent reloads)

image notice the #(KUBE_TMUX_SYMBOL_ENABLE=false kube-tmux/kube.tmux 250 '#f38ba8' '#89dceb') before and #(KUBE_TMUX_SYMBOL_ENABLE=false /home/user/.tmux/plugins/kube-tmux/kube.tmux 250 '#f38ba8' '#89dceb') after reload.

pauldthomson commented 2 months ago

Before:

:!tmux show-options -g status-right
status-right "#[fg=#{?client_prefix,#f38ba8,#a6e3a1},bg=default,nobold,nounderscore,noitalics] #[fg=#1e1e2e,bg=#{?client_prefix,#f38ba8,#a6e3a1},nobold,nounderscore,noitalics] #[fg=#cdd6f4,bg=#313244] #
S#[fg=#313244,bg=default,nobold,nounderscore,noitalics]#[fg=#89b4fa,bg=default,nobold,nounderscore,noitalics] #[fg=#1e1e2e,bg=#89b4fa,nobold,nounderscore,noitalics]󱃾 #[fg=#cdd6f4,bg=#313244] #(KUBE_TMUX
_SYMBOL_ENABLE=false kube-tmux/kube.tmux 250 '#f38ba8' '#89dceb')#[fg=#313244,bg=default,nobold,nounderscore,noitalics]"

after:

:!tmux show-options -g status-right
status-right "#[fg=#{?client_prefix,#f38ba8,#a6e3a1},bg=default,nobold,nounderscore,noitalics] #[fg=#1e1e2e,bg=#{?client_prefix,#f38ba8,#a6e3a1},nobold,nounderscore,noitalics] #[fg=#cdd6f4,bg=#313244] #
S#[fg=#313244,bg=default,nobold,nounderscore,noitalics]#[fg=#89b4fa,bg=default,nobold,nounderscore,noitalics] #[fg=#1e1e2e,bg=#89b4fa,nobold,nounderscore,noitalics]󱃾 #[fg=#cdd6f4,bg=#313244] #(KUBE_TMUX
_SYMBOL_ENABLE=false /Users/paul/.tmux/plugins/kube-tmux/kube.tmux 250 '#f38ba8' '#89dceb')#[fg=#313244,bg=default,nobold,nounderscore,noitalics]"

Seems you're on to a winner... I'll have a look in the TPM repo

pauldthomson commented 2 months ago

Yeah odd, seems it should always get set when launching tmux: https://github.com/tmux-plugins/tpm/blob/99469c4a9b1ccf77fade25842dc7bafbc8ce9946/tpm#L26-L35

Will need to dig some more

pauldthomson commented 2 months ago

So the issue seems to be that setting the tmux env var this way: https://github.com/tmux-plugins/tpm/blob/99469c4a9b1ccf77fade25842dc7bafbc8ce9946/tpm#L34 doesn't actually get sent to the initial shell spawned inside the tmux window: https://stackoverflow.com/questions/20701757/tmux-setting-environment-variables-for-sessions#comment114609472_49395839

I added an export "$DEFAULT_TPM_ENV_VAR_NAME"="$tpm_path" below the line from tpm above and it fixes the issue.

I'm not sure why this hasn't been noticed before, perhaps not many other things rely on this env var?

I'll open an issue on tpm and see what the response is, and see if perhaps there's a cleaner way to fix this.

vdbe commented 2 months ago

A better solution would be to escape the dollar sign so the env var is interpreted during the status update.

pauldthomson commented 2 months ago

A better solution would be to escape the dollar sign so the env var is interpreted during the status update.

Yeah, I thought there was an issue with the way tpm was setting that var so figured it would be good to fix at the source but looks not to be the case anyway. I'll raise a minor PR here..