Tech

Moving Around (pushd & popd): Notes: List of Terminal Commands

Moving Around (pushd & popd)

pushd (push directory) & popd (pop directory) let you temporarily go to a different-directory, and then come back, easily switching between the two!!

pushd–lets you save your current location and go to a new location. The “pushd” command takes your current directory and “pushes” it into a list for later, then it ‘changes’ to another directory. It’s like saying, “Save where I am, then go here.”

popd–lets you return to the saved location. The “popd” command takes the last directory you pushed and “pops” it off, taking you back there.

Note: On Unix-machines “pushd“, if you run it by itself with no arguments, will switch between your current directory and the last one you pushed. It’s an easy way to switch between two directories!

Note: Also, remember that “mkdir –p” (on Linux/Mac) will make an entire path, even if all the directories don’t exist. Ex: mkdir -p i/like/icecream