Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use "cd -" to jump back and forth between two directories.

Is there a command that will rotate between three directories?

share|improve this question
2  
If the directories you are using are static, you can just add a permanent alias to your .bashrc file. If you add a full path you can use simple commands to jump between the directories. –  Eugene S Feb 23 '12 at 9:57

6 Answers 6

There are commands (builtins) to maintain a stack of directories: pushd and popd.

share|improve this answer
3  
Care to elaborate a bit more? Given that the user didn't find these 'simple' commands, I reckon there's more to it then just mentioning their name –  Ivo Flipse Feb 27 '12 at 15:28
2  
use man builtins to get info on pushd, popd, and dirs. Set up convenient aliases to navigate. e.g. after 2 pushes, pushd +1 will rotate through the 3 directories. –  libjack Feb 29 '12 at 20:07

pushd and popd can be used here, however unlike the former poster: see also this howto once you have populated the $DIRSTACK with directories you can also use dirs and cd ~1 to jump to directories in $DIRSTACK directly!

share|improve this answer

First add the second and third directories to the directory stack (your working directory is already in the stack).

pushd second/directory/path
pushd third/directory/path

Then rotate through your directories with the following command:

pushd +1
share|improve this answer

Maybe this is too obvious, open two or three terminals and run mc in them?

share|improve this answer

pushd/popd and $DIRSTACK solutions proposed in other answers are the "canonical" way.

Another option would be to use screen command. You open your directories in different sreens and switch between next/previous using shortcuts - Ctrl-a n for next and Ctrl-a p for previous. Or using Ctrl-a anyNumber to go to a specific screen. Or using Ctrl-a doublequote to display and visually select which screen you want.

Check all possible window navigation shortcuts.

share|improve this answer

Try using 'z' link. It remember which directories you have been to and you can jump around with short commands and abbreviated directory names.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.