After reading multiple questions on this topic I still feel lost. I read suggestions that one should set the environment variables including $PATH
in .profile
instead of specifically in .bashrc
or .zshrc
, and this is what I did.
My default shell is zsh
and I have set set-option -g default-shell $SHELL
in tmux.conf
.
However, now whenever I launch tmux sessions, it apparently doesn't pick up any modification to $PATH
and only sources .zshrc
. My current workaround is to add source ~/.profile
at the end of .zshrc
, which I don't think is the right thing to do.
This post indicates that tmux/screen usually runs as subshells instead of login shells, and thus don't necessarily source .profile
. However, another post claimed that if you can run logout
in the shell, it is a login shell, which I was indeed able to. Many posts also claimed that tmux
should look for .bash_profile
plus .profile
, but would overlook .bashrc
, which is apparently not what happened in my case of the zsh equivalent.
What is the best practice to use tmux with zsh and have it properly pick up environment variables, after all?