How to stop bare bash cd (change directory command) from changing the working directory to $HOME?

wodow asked:

I do this too often:

$ pwd
/a/long/long/way/from/anywhere
$ cd # oops - meant to tab-complete something
/home/$USER

Can cd defaulting to $HOME be disabled?

My answer:


In bash, if you accidentally change to the wrong directory, you can go back to the previous directory with:

cd $OLDPWD

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.