Back to TIL
Today I Learned Quick knowledge bits

Pushd and popd commands

· 1 min read
Updated:

I feel stupid for only finding those today. After years in the terminal.

pushd saves the current directory on a stack, changes to a specified directory. Then popd changes back to the top directory and pops it.

Terminal window
pushd /var/log # Now in /var/log, stack contains /home
pushd /etc # Now in /etc, stack contains /var/log, /home
popd # Returns to /var/log
popd # Returns to /home

I love those for aliases with agents or for executing build scripts.

Major downside is they are very noisy, so you always got to > /dev/null.