I love zsh
, but I am not sure where to place my $PATH
and other variable assertions? I find that they are scattered between the files .zshrc
.zprofile
.bashrc
.bash_profile
, and sometimes doubled.
I realize that having anything inside the bash
files doesn't make much sense seeing as I'm using zsh
, but where exactly should I be placing my rvm
, python
, node
etc additions to my $PATH
?
Is there a specific file I should be using (i.e. .zshenv
which does not currently exist in my installation), one of the ones I am currently using, or does it even matter?
tl;dr version: use
~/.zshrc
And read the man page to understand the differences between:
Regarding my comment
In my comment attached to the answer kev gave, I said:
This turns out to be partially incorrect:
/etc/profile
may be sourced byzsh
. However, this only occurs ifzsh
is "invoked assh
orksh
"; in these compatibility modes:The ArchWiki ZSH link says:
This implys that
/etc/profile
is always read byzsh
at login - I haven't got any experience with the Arch Linux project; the wiki may be correct for that distribution, but it is not generally correct. The information is incorrect compared to the zsh manual pages, and doesn't seem to apply to zsh on OS X (paths in$PATH
set in/etc/profile
do not make it to my zsh sessions).To address the question:
Generally, I would export my
$PATH
from~/.zshrc
, but it's worth having a read of the zshall man page, specifically the "STARTUP/SHUTDOWN FILES" section -~/.zshrc
is read for interactive shells, which may or may not suit your needs - if you want the$PATH
for everyzsh
shell invoked by you (bothinteractive
and not, bothlogin
and not, etc), then~/.zshenv
is a better option.There's a bunch of files read on startup (check the linked
man
pages), and there's a reason for that - each file has it's particular place (settings for every user, settings for user-specific, settings for login shells, settings for every shell, etc).Don't worry about
~/.zshenv
not existing - if you need it, make it, and it will be read..bashrc
and.bash_profile
are not read byzsh
, unless you explicitly source them from~/.zshrc
or similar; the syntax betweenbash
andzsh
is not always compatible. Both.bashrc
and.bash_profile
are designed forbash
settings, notzsh
settings.I had similar problem (in bash terminal command was working correctly but zsh showed command not found error)
Solution:
just paste whatever you were earlier pasting in ~/.bashrc to:
Here is the docs from the zsh man pages under STARTUP/SHUTDOWN FILES section.
From this we can see the order files are read is:
You can get more information here.