How can I get the behavior of using popd without actually popping the last directory off of the stack? In other words, I want to navigate back to the last directory that I set with pushd, but I want it to stay at the top of the stack so the next popd will take me to that same directory (which would still be on the top of the stack) again.
Asked
Active
Viewed 1,930 times
9
Freedom_Ben
- 9,532
3 Answers
10
pushd with no arguments swaps the top two entries on the stack, allowing you to effectively cd back and forth between them.
Starting out in d1, execute pushd d2 adds d1 and d2 to the stack and leaves you in d2. Execute pushd again with no arguments, and you're back in d1 with d1 and d2 reversed on the stack.
Stephen Davison
- 101
6
If I understood correctly, you could pushd . just after popd so the poped directory will be placed again at the top of the stack.
Eric Carvalho
- 55,453