DEV Community

Discussion on: #OneDevMinute: Go back to the Previous Directory

Collapse
 
hoelzro profile image
Rob Hoelz

I think popd pops off of the directory history stack, rather than the directory hierarchy itself; so if you do this:

$ pushd /tmp
$ pushd
$ pushd projects/

followed by popd; popd, you'll end up in /tmp/ once again. I'm guessing that autopushd aliases cd to pushd to make this more automatic; in zsh cd does that by default.

Thread Thread
 
ahmadawais profile image
Ahmad Awais ⚡️

Makes a lot of sense. And I think typing

-

to go to prev dir is quite easy for me to remember. Wouldn't you agree? 🤔

Thread Thread
 
val_baca profile image
Valentin Baca

correct, popd uses the pushd history; it does not use the directory hierarchy. Use cd .. for that.