Re:Console productivity hack: Discover the frequent; then ma...
by koenigdavidmj on Sunday October 10, 2010 @03:11AM
(#1776726)
You can also say `cd -` on Bourne shells to go back to the previously visited directory. If you move from A to B in this manner and then run it again, then you will go back to A.
Also, `alias cd=pushd` to get that same zsh functionality in other Bourne shells.
`pushd` switches directories and maintains a stack of visited directories. `popd` pops the previous directory off the stack and then switches to it.
In zsh, it seems that `cd` is an alias for `pushd`. You can `cd` to a directory, then `popd` to go back.
In Windows, `pushd` seems to the easiest/only way to navigate to network directories on the command-line.