0

Say I do the following:

cd ~
pushd .
cd /bin/
pushd .
dirs
"/bin/ ~/
cd ~/Downloads/
pushd .
dirs
~/Downloads /bin/ ~"

How would I popd back to something a while ago, say from downloads to the home directory~?

polym
  • 10,672
  • 9
  • 41
  • 65
user73959
  • 23
  • 2

1 Answers1

1

Depending on your shell, for zsh you can just use cd -N to change to your Nth previous directory.

For bash you can use for example dirs to get a directory name. You can use that to do something like cd "$(dirs -N)" which will go the the Nth previous directory, just like the zsh example above.

Ulrich Dangel
  • 25,079
  • 3
  • 80
  • 80