You probably are looking for something like the
CDPATH shell variable.
CDPATH variable acts like
PATH but for the
Setting with something like
would allow you to say
anywhere, and it would go through the
:-separated directory paths in the
$CDPATH value in order until it found a subdirectory called
ricky_martin somewhere (possibly
~/music/ricky_martin) and then
may take you to
~/projects/world_domination if there is such a subdirectory. If
world_domination also existed in the current directory, this directory would be selected first as it occurs earlier in
$CDPATH (the dot in the first position).
It would also be allowed to do
from anywhere to get to
~/projects/proj1/tests if such a directory existed (with the above
$CDPATH value, unless
proj/tests did not exist in the current directory or in your home directory).
Note that the
CDPATH shell variable should not be exported as that may seriously confuse some scripts.
CDPATH variable is documented in the
bash manual (
The search path for the
cd command. This is a colon-separated
list of directories in which the shell looks for destination
directories specified by the
cd command. A sample value is