Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to write a symbolic link such that no matter where am I on the file system, I can use for example project to point the directory home/me/project? I would like to use commands like cd project, nano project/file1.tex and so on. Do I have to write a symbolic link to all of my directories?

share|improve this question
up vote 14 down vote accepted

Most shells have a CDPATH variable that cd can lookup for directories to change to in the same way that executables are searched in $PATH.

So if you add your symlinks in a ~/projects directory and do CDPATH=~/projects, you'll be able to do cd foo to go in ~/projects/foo

With zsh, if $var contains a path you can do cd ~var to cd to that path. The useful part of that is when your prompt has %~ which then reflects it in your prompt:

$ proj1=/usr/local proj2=/etc/apache2
$ PS1='%~$ '
$ cd ~proj1
~proj1$ cd ~proj2/sites-enabled

With setopt cdablevars, you can also do cd proj1 instead of cd ~proj1.

share|improve this answer

You probably want to use variables instead of symbolic links, e.g.

export project=/home/me/project


cd $project


vim $project/file


As pointed out by peterph, you can also combine these (including predefined variables), e.g.

export project=$HOME/project
share|improve this answer
Or even better project=$HOME/project... – peterph Apr 30 '14 at 14:40
@peterph, or even simpler ~/project. – Stéphane Chazelas Apr 30 '14 at 14:54
With zsh, you can also do setopt cdablevars and then cd project – Stéphane Chazelas Apr 30 '14 at 14:56
@StephaneChazelas: I think that's a good point - though as it's specific to zsh perhaps you could add that as a separate answer? – jmetz Apr 30 '14 at 14:58

Your Answer


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.