tmux always modify my zsh PATH
I'd like to use tmux inside my iTerm2.
and I have the following in my ~/.tmux.conf file.
set-option -g default-shell /bin/zsh
set-option -g default-command "/bin/zsh -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace /bin/zsh -l || exec /bin/zsh -l'"
In my iTerm2, I set /bin/zsh to my default shell too.
The output of echo $PATH
inside iTerm2 but outside tmux is the following:
/Users/alex/.pyenv/plugins/pyenv-virtualenv/shims
/Users/alex/.pyenv/shims
/Users/alex/tools/gradle-2.13/bin
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin
/Users/alex/.pyenv/bin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
but inside tmux, echo $PATH
prints the following:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin
/Users/alex/.pyenv/plugins/pyenv-virtualenv/shims
/Users/alex/.pyenv/shims
/Users/alex/tools/gradle-2.13/bin
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin
/Users/alex/.pyenv/bin
It seems that tmux has put the /usr/local/bin
etc in front of my PATH setting, which makes pyenv can not find the correct python.
My ~/.zshenv
is :
alias vim="nvim"
PATH="/usr/local/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export GRADLE_HOME=/Users/alex/tools/gradle-2.13
export PATH=$GRADLE_HOME/bin:$PATH
export HOMEBREW_GITHUB_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxx
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
and my ~/.zhrc
is :
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export LANG=en_US.UTF-8
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
So what is wrong here?
Do I miss something during tmux starts up?
After googling, I've found this:
https://coderwall.com/p/4l16zq/pyenv-inside-tmux-with-zsh-on-a-mac http://pgib.me/blog/2013/10/11/macosx-tmux-zsh-rbenv/
And the fix to me is that (/etc/zprofile):
# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
if [ -z "$TMUX" ]; then
eval `/usr/libexec/path_helper -s`
fi
fi