2 ms·
CDPATH is kind of flawed. It wants to be a mapping feature. So that is to say, when I type "cd foo", I want foo to be "cd alias" for some "/path/to/foo" or pos
by kazinator 3y ago
CDPATH is kind of flawed. It wants to be a mapping feature.
So that is to say, when I type "cd foo", I want foo to be "cd alias" for some "/path/to/foo" or possibly even "/path/to/bar". I know where I want to go; I don't need a search to find it!
Fortunately, there is a way to get that with CDPATH. You can make some directory, say /home/yourself/.cdfarm.
Inside .cdfarm/, you have symlinks to various directories
foo -> /path/to/foo
bar -> /path/to/elsewhere/bar
and you put this .cdfarm into your CDPATH:
CDPATH=:~/.cdfarm
and that's it, all other management is via ~/.cdfarm.
Unfortunately, the symlinks appear in the PWD, unless you use "cd -P"; for that you can "alias cd='cd -P".
Even if you use -P, when Bash's cd resolves something via CDPATH, it prints the target path name with the /home/yourself/.cdpath/... in it, as it appears before -P resolution. That's not necessarily a bad thing; it reminds you of how you are getting to where you are.