I have in .zshrc
setopt autopushd
It makes cd acts like pushd. This means that we have no stack at all. When I have used it, I have not used stack at all, since it removes stack from me.
I am not sure what is the benefit of autopushd.
What is the benefit of autopushd?
pushd is like cd, but it also pushes your current directory onto a stack. You might be in /some/deep/directory and then need to poke around in /var/www for a while:
autopushd means that even if you type 'cd', you get the effect of having typed 'pushd', which you don't remember you wanted to use until you think "man, I really wish I could get back to where I was before". You can then popd your way back through your directory history.
It's useful to know you can always change to the directory you were in before this one (as opposed to the parent directory) by typing 'cd -'.
Here's another good writeup.
Edit Why use pushd when you can use cd - ?
cd - will only get you up to /baz. pushd will get you all the way back up to where you were before you typed 'cd /foo/bar'.
The directory stack is particularly useful in scripts, where you can't just go back through your command history and recognize the name of the directory you were in:
You are now guaranteed to be in /var/foo.
The AUTO_PUSHD option lets you use cd to get back to any directory you've ever cd'ed to. Without this option you are only able to get back to the previous directory you've cd'ed to but with this option you can use something like
cd -5
to get back to the 5th directory you've visited.