pushd and popd. Thank me later.
Anyway, since we are on the topic of directory navigation, I'd like to introduce 'cd -' (toggle to previous dir). Thank me later :-)
First example:
type -a <something>
to discover what <something> is (or if it exists on your system)Try man -a {pushd,popd} you can also use the man -k flag to find manpages, and see man man (or man --help) for more flags.
Another neat way of wrapping code in pushd/popd is to use a subshell.
(cd $dir
do-stuff
)
Oilshell ( https://www.oilshell.org/ ) has support for code blocks so you can: cd /tmp {
do-stuff
}Ironically, 'man help' yields no results.