tmux-plugins / tpm

Tmux Plugin Manager
MIT License
12.17k stars 429 forks source link

tmux with TPM does not apply zsh configuration after startup #295

Open okm321 opened 2 weeks ago

okm321 commented 2 weeks ago

Issue

After installing some tmux plugins using TPM (Tmux Plugin Manager), tmux starts with zsh, but the zsh configuration (e.g., .zshrc) does not get applied automatically. I have to manually run $SHELL or exec zsh to apply my zsh settings. This issue only occurs when using TPM; without TPM, zsh works as expected.

Expected Behavior

When I start a new tmux session, it should load my zsh shell with all configurations from .zshrc as expected, even when TPM is used.

Current Behavior

When using TPM, tmux starts with zsh, but the configuration from .zshrc is not applied. This forces me to run $SHELL or exec zsh manually to load my settings. Without TPM, tmux loads zsh with the correct configuration as expected.

Steps to Reproduce

  1. Install tmux and TPM (Tmux Plugin Manager)
  2. Install any plugin using TPM.
  3. Start a new tmux session and observe that zsh starts, but the configuration (e.g., aliases or environment variables) is not applied.
  4. Remove TPM or disable plugins, then start tmux again to see that zsh's configuration is loaded correctly.

System Information

CleanShot 2024-10-14 at 15 48 20

tmux.conf

.tmux.conf ``` TMUX_PLUGIN_MANAGER_PATH="~/.tmux/plugins" # List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-continuum' set -g @plugin 'catppuccin/tmux#latest' set -g @plugin 'tmux-plugins/tmux-pain-control' set -g @plugin 'tmux-plugins/tmux-battery' set -g @plugin 'xamut/tmux-weather' set -g @catppuccin_flavor 'mocha' # latte,frappe, macchiato or mocha ## catppuccin config set -g @catppuccin_window_left_separator "█" set -g @catppuccin_window_middle_separator "█ " set -g @catppuccin_window_right_separator_inverse "yes" set -g @catppuccin_window_right_separator "█" set -g @catppuccin_window_number_position "left" set -g @catppuccin_window_default_fill "number" set -g @catppuccin_window_current_fill "number" set -g @catppuccin_window_default_text "#W" set -g @catppuccin_window_current_text "#W" set -g @catppuccin_window_default_color "#{thm_black4}" # text clor set -g @catppuccin_window_default_background "#{thm_bg}" set -g @catppuccin_window_current_color "#{thm_magenta}" # text color set -g @catppuccin_window_current_background "#{thm_bg}" set -g @catppuccin_directory_color "yellow" set -g @catppuccin_status_modules_left "session" set -g @catppuccin_status_modules_right "directory gitmux application date_time weather battery" set -g @catppuccin_weather_color "orange" set -g @catppuccin_battery_color "magenta" set -g @catppuccin_gitmux_color "blue" set -g @catppuccin_status_left_separator "█" set -g @catppuccin_status_right_separator "█" set -g @catppuccin_status_right_separator_inverse "yes" set -g @catppuccin_status_fill "all" set -g @catppuccin_gitmux_text "#(gitmux -cfg $HOME/.gitmux.conf \"#{pane_current_path}\")" set -g @catppuccin_status_connect_separator "no" ## pane set -g @catppuccin_pane_status_enabled "on" set -g @catppuccin_pane_border_status bottom set -g @catppuccin_pane_border_style "fg=#{thm_gray}" set -g @catppuccin_pane_active_border_style "fg=#{thm_magenta}" set -g @catppuccin_status_background "default" set -g status-interval 1 # ウィンドウを切り替える bind -n S-left previous-window bind -n S-right next-window # マウス操作を有効にする set-option -g mouse on # prefix+r で設定のリロード bind r source-file ~/.tmux.conf \; display "Reloaded!" set-window-option -g mode-keys vi # PaneをVim-likeに移動する bind -r k select-pane -U bind -r j select-pane -D bind -r h select-pane -L bind -r l select-pane -R # window、paneの追加時に同一ディレクトリで開くようにする bind c new-window -c '#{pane_current_path}' bind '"' split-window -c '#{pane_current_path}' bind % split-window -h -c '#{pane_current_path}' # ステータスバーを上部に表示する set -g status-position top # checkhealth回避用 set -g escape-time 10 set -g focus-events on bind-key -T copy-mode-vi v send-keys -X begin-selection bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy" set -g default-terminal "tmux-256color" # set -ag terminal-overrides ",alacritty:RGB" set-environment -g PATH "/opt/homebrew/bin:/usr/local/bin:/bin:usr/bin" # プラグインマネージャの初期化(とりあえず最下部に記載) run '~/.tmux/plugins/tpm/tpm' ```
trobrock commented 2 weeks ago

I believe I'm experiencing the same thing after a brew upgrade this morning. I upgraded to tmux 3.5a.

trobrock commented 2 weeks ago

Disabling all my plugins except tpm seems to work, and then the shell is broken again once I add in tmux-sensible.

Update: I've narrowed it down to this line https://github.com/tmux-plugins/tmux-sensible/blob/master/sensible.tmux#L103

I'f I manually set set-option -g default-command "reattach-to-user-namespace -l /bin/zsh" in my tmux config, the shell remains working. I suspect something with the $SHELL var.

gAmUssA commented 6 days ago

i have the same problem. @trobrock solution helped

veselyn commented 5 days ago

The problem is that TPM sources plugins with run-shell which executes a shell command with /bin/sh but until recently wasn't also setting $SHELL to /bin/sh.

Source: https://github.com/tmux/tmux/issues/4166#issuecomment-2403427896

von commented 1 day ago

Seeing this problem as well and tracked it down to $SHELL being set to sh instead of zsh in tmux-sensible before finding this issue, so what @veselyn reports makes sense to me.

The work around suggested by @trobrock works for me, by setting default-command in my .tmux.conf this prevents tmux-sensible from setting it , i.e.:

set -g default-command "reattach-to-user-namespace $SHELL"