by codegeek · 4y ago · 0 comments
cd -
This takes you to the last directory you were in (not the same as cd .. which takes you one level up) $ pwd
/foo
$ pushd /bar && pwd
/bar
$ pushd /quux && pwd
/quux
$ popd && pwd
/bar
$ popd && pwd
/foo
So it's basically a stack.Never seen {push,pop}d in a shell script.
As an interactive feature, I use the "autopushd" option in zsh, which make all "cd" behave like pushd, and you can also use "cd -n" where "n" is the number of levels you want to go up the stack (so "cd -" is equivalent to "cd -1")