Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I made the mistake of putting CDPATH into my .profile file just to see if it would slightly boost my productivity but found that sometimes it would cd to directories that I didn't want it to (I would need to precede them with ./ to make sure it went to the current directory rather than one defined in the environment variable that shared the same name).

I removed it from the .profile file but it still gets exported every time I launch the terminal and for the life of me I can't find what (bash) script does it.

I would search/etc and my home directory for any file the name of which resembles profile or bash and xargs grep those files to look if there were something along the lines of export CDPATH but to no avail.

Is this stored in a configuration file that cd uses? Has anyone come across a similar problem?

Needless to say I did put export CDPATH='' in my .profile, but I need to source it first for the statement to take effect.

My bash version is 4.2.24, my OS is Linux Mint 13 Cinnamon.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Your .profile will be read when you log in not when you start a new shell. This includes when you log in to a graphical display manager, which I assume you are doing ("every time I launch the terminal"). If you're in a graphical interface, log completely out of that and back in to get a fresh environment.

EDIT: For future reference, I recommend putting stuff like that in a .bashrc file instead of .profile. The .bashrc is read every time a shell is started. This page does a good job of explaining the difference in more detail.

share|improve this answer
    
Yes, it was indeed the issue, I was using a virtual environment whose state I was saving and once logged in, the variable was there until I would restart it. I had assumed that the CDPATH would be unset for all terminals if I did it in one but it wasn't the case. I'll keep it in mind :) –  Nobilis May 26 '13 at 4:55

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.