Is it possible to set a symbolic link so that I can use project to point the directory home/me/project, e. g.? This should be independent of the location in the file system.

I'd 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?


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.


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
  • 1
    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
  • 4
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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