Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: CDPATH?



On Sun, 4 Jan 2009, Webb Sprague wrote:

Hi all,

I can't get CDPATH to work as I expect -- can someone help?  See below
for more info.

(0) foobar:wsprague [0]% setopt autocd
(1) foobar:wsprague [0]% echo $CDPATH
       <1186>
~/DEMOG/PAPERS-PRESENTATIONS-ETC/DISSERTATION/NLSY
(0) foobar:wsprague [0]% cd NLSY
       <1187>
cd: no such file or directory: NLSY
(1) foobar:wsprague [0]%


Two minor problems:

1. The tilde won't be expanded. (Some problem with quotes when you set CDPATH?)

2. As with 'PATH', CDPATH should contain the folder that contains the thing you're looking for.

So, the following should work to set up what you want:

CDPATH=~/DEMOG/PAPERS-PRESENTATIONS-ETC/DISSERTATION

(Note the lack of quotes.)


Personally, when I want something like this, I set up a named alias for the directories:

hash -d assignment=~/lti/11-741/3/assignment
hash -d writeup=~assignment/writeup

Then I can do:
% ~a<Tab>
% ~assignment<Enter>

to cd to /home/bhaskell/lti/11-741/3/assignment

It seems a little more controlled than CDPATH, and you can use it in more situations (not just 'cd'). ( e.g. rm ~writeup/bhaskell-3.pdf )

Best,
Ben



Messages sorted by: Reverse Date, Date, Thread, Author