Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
okm321 opened this issue Oct 14, 2024 · 6 comments
Open

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

okm321 opened this issue Oct 14, 2024 · 6 comments

Comments

@okm321
Copy link

okm321 commented Oct 14, 2024

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

  • OS: macOS v15.0.1
  • Shell: zsh (installed via Homebrew)
  • Tmux Version: 3.5a
  • TPM Version: 3.1.0

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
Copy link

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

@trobrock
Copy link

trobrock commented Oct 16, 2024

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
Copy link

gAmUssA commented Oct 25, 2024

i have the same problem. @trobrock solution helped

@veselyn
Copy link

veselyn commented Oct 26, 2024

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: tmux/tmux#4166 (comment)

@von
Copy link

von commented Oct 30, 2024

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"

@rovangju
Copy link

rovangju commented Nov 2, 2024

Got bit by this too - thanks all for the fixes! Hate it when something obscure like this pops up from a simple update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants