1

Using iTerm2 with tmux and zsh. I have an issue that new tmux panes doesn't source ~/.zshrc file

I have customized my terminal (when running source ~/.zshrc manually it works) but when opening new pane (C+b and c) it doesn't source the file

~/.tmux.conf

set -g default-terminal "screen-256color" set -g default-command /bin/zsh set-option -g default-shell /bin/zsh 

~/.zshrc

export ZSH="$HOME/.oh-my-zsh" plugins=(git tmux) ZSH_TMUX_AUTOSTART=true source $ZSH/oh-my-zsh.sh if [[ -n $SSH_CONNECTION ]]; then export EDITOR='vim' else export EDITOR='mvim' fi export TERM=xterm-256color eval "$(starship init zsh)" 

iTerm settings [iTerm settings1

current terminal (on new pane) current status

wanted terminal (on new pane) enter image description here

10
  • I suspect this is a login-shell (or not) distinction. What happens if you set the default-command to "/bin/zsh -l" and then reload or restart tmux? Commented Jul 18, 2022 at 13:19
  • Hi do you mean inside the tmux config file right ? tired and still same result Commented Jul 18, 2022 at 13:34
  • How did you restart tmux and what exactly did you put into tmux.conf? Commented Jul 19, 2022 at 13:51
  • tmux kill-server and set -g default-command "/bin/zsh -l" Commented Jul 19, 2022 at 14:08
  • tmux source-file ~/.tmux.conf should be less brutal than kill-server. Can you add a print foo at the top ~/.zshrc for diagnostics? In theory it should be being read by zsh. (Maybe oh-my-zsh or whatever ZSH_TMUX_AUTOSTART=true does complicates matters?) Commented Jul 19, 2022 at 15:20

1 Answer 1

0

I figured out that for some reason, when I use chsh my default terminal will also load the same config (aka non) as my tmux.

Check where your $ZDOTDIR is pointing:

$ echo $ZDOTDIR /Users/<you>/.config/zsh 

Sadly I had that folder for other configs.. referencing from my .zshrc. Fun fact, in my work laptop this doesn't cause an issue, but does on the personal.

My solution was to move ~/.zshrc to ~/.config/zsh/.zshrc and create a symlinc:

$ mv .zshrc .config/zsh/ $ ln -s .config/zsh/.zshrc .zshrc 

This way, both the normal terminal opening works, (Same in alacritty and the default mac terminal) and also tmux.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.