2 edited tags
| link
source | link

open a file using CDPATH and symlink

To quickly move around, I added a path to CDPATH that contains symlinks to different locations. I did this by adding the following line to .bashrc:

export CDPATH=~/symlinks

When working with directories, everything's fine and I can access the symlinked folders from everywhere.

For example if I do:

$ ln -s ~/path/to/folder ~/symlinks/folder

I can then just write:

$ cd folder

to get inside the symlinked folder, regardless of my current directory.

However, when I create a symlink to a file and then try to open it with an editor, I get an empty file, unless I'm in the symlink directory.

For example if I do:

$ ln -s ~/path/to/file/filename ~/symlinks/filename

and then write:

$ kwrite filename

I get an empty file, if I'm not in the symlink folder.

I want to access the file from anywhere though, how can I achieve this?