Take the 2-minute tour ×
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.

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
add comment

1 Answer

up vote 2 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
add comment

Your Answer

 
discard

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.