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.

Is there a way to go to any directory from any other directory directly? For example, lets say that I'm at root and I wanted to go directly to currentProject without doing:

cd dropbox/dev/currentProject



-root
  -dropbox
     -dev
        -currentProject

Is there way to do this?

share|improve this question

7 Answers 7

up vote 21 down vote accepted

You can use something like autojump. Autojump lets you quickly jump to frequently visited directories with the j command.

For instance, once you've cd'd into your currentProject directory a few times, you can jump to it like this:

j currentProject

You can even use just part of the directory name. So you could do:

j current

To cd into currentProject.

share|improve this answer

You can also add some common directories to your $CDPATH

export CDPATH=$HOME

This for example will let you cd into any dir in your home folder from anywhere in your system.

more

share|improve this answer

This doesn't answer your question directly, but if I'm inferring correctly that you're going to be jumping between directories a lot, you could use a terminal multiplexer like GNU Screen to keep the different directories open in different windows, and simply switch between them as needed. I personally use Byobu, which adds some functionality on top of screen.

share|improve this answer
1  
See also: tmux. –  Adam Backstrom May 23 '11 at 3:44

You can set an alias in your bash profile. Basically that lets you abbreviate a command with a word. You could set currentProject actually point to /dropbox/dev/currentProject

share|improve this answer

You could create symlinks in your home directory to where you want to go.

ln -s /dropbox/dev/currentProject ~/currentProject

This way, you're still using cd, but you don't have to remember the full path. Just use:

cd ~/currentProject

When you stop using the link, just delete it.

rm ~/currentProject
share|improve this answer

As Wuffers mentioned above, autojump that can do this for you. It stores a database of previously visited directories and lets you use a command like j <a few letters in the directory path> to move to that directory. There is an additional command for autojump named jc that should meet your requirements. jc lets you jump to a previously visited subdirectory of the current working directory. So you only have to visit the directory once for this to work until you purge the autojump database. Also, you can also add it directly instead with autojump --add DIR (perhaps building the add list from a directory tree listing if needed).

share|improve this answer

In bash and *csh, there is the builtin commands 'pushd' and 'popd' that allow you to push directories onto a Last In First Out stack (with pushd [directory]) and then quickly change to the top directory in the stack using 'popd'. So, depending on how you loaded the stack, you might be able to quickly navigate between directories suitably well for this to be functional for you.

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.