Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to alter my PATH variable so I put export PATH=$PATH:somedir in my $HOME/.profile which is sourced by my $HOME/.zshrc.

This works, yet whenever I open a new terminal (urxvt in X11), .zshrc and thus .profile is read, adding the :somedir to the PATH again.

In my day to day computer use, the terminal windows come and go a lot, so after three hours of usage the PATH variable contains hundreds of clones of the :somedir appendix.

How do I fix this? Is there a config file which is read by zsh only on login?

share|improve this question
up vote 3 down vote accepted

From the zsh man page:

[...] Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.

You should do your PATH changes in .zprofile (that could source .profile if you want), not in .zshrc.

share|improve this answer
Much better than my own answer. Thank you. – Sardathrion Aug 30 '12 at 10:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.