Having some problems googling this one because I'm not sure what the search term is. Shell scripting or terminal feature. What is the best way to streamline access to frequently used directories. Normally when I start a terminal it defaults to my home directory but sometimes I ike to open several terminal windows, the problem is I'm typing the cd /.../directory in each one multiple times and I need a way to not have to do this. What is the best way or just provide the search terms I could use to read about it online. Thank you

link|improve this question
create alias for each directory that you very often use. Also use cd - to go back to last directory that you accessed – Prince John Wesley Nov 10 '11 at 17:04
feedback

migrated from stackoverflow.com Nov 11 '11 at 3:08

This question came from our site for professional and enthusiast programmers.

6 Answers

up vote 3 down vote accepted

Create a symbolic link in your home directory:

$ ln -s path/to/a/really/deeply/nested/director/my-project ~/my-project

$ cd ~/my-project
link|improve this answer
feedback

Add a variable in your .bashrc:

MYPROJECT=path/to/a/really/deeply/nested/director/my-project

to use:

$ cd $MYPROJECT
link|improve this answer
feedback

Set the CDPATH variable: it contains additional directories to be searched when you run cd.

link|improve this answer
feedback

You could use a bookmarks for the shell, e.g. bookmarks.sh.

link|improve this answer
feedback

You can also take advantage of CDPATH variable.

And you could define a bash function in your $HOME/.bashrc like

 # in file ~/.bashrc
 function work() {
    cd $HOME/path/to/a/really/deeply/nested/director/my-project
 }

And recent bash or even better zsh may permit you things like

 cd **/my-project

Assuming you have only one deeply nested my-project/ directory in all your tree hierarchy. The ** is doing the equivalent of a find so can be slow.

link|improve this answer
feedback

Add an alias in your .bashrc

alias myproject="cd path/to/a/really/deeply/nested/director/my-project"

to use:

$ myproject
link|improve this answer
feedback

Your Answer

 
or
required, but never shown