LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   CDPATH not working (http://www.linuxquestions.org/questions/slackware-14/cdpath-not-working-4175436679/)

markush 11-11-2012 01:29 PM

CDPATH not working
 
Hello,

I've read about CDPATH in this http://docs.slackware.com/howtos:sof...igation#cdpath Howto at SlackDocs. But it doesn't work here.

I've read the manpage for bash and think it should work like described in the Howto.

By default $CDPATH is not set, is this correct?

Now I have
Code:

CDPATH=$CDPATH:/tmp/
put in my .bashrc.
Code:

markus@samsung:~$ echo $CDPATH
:/tmp/

After sourcing .bashrc I thought that I could cd into directories in /tmp/ with only the name of the directory, but this doesn't work. I have also tried it with directories in my ~/ directory, this doesn't work as well.

Any Ideas?

Markus

sycamorex 11-11-2012 01:49 PM

Hi Marcus,

I think that the description entry in the wiki is misleading (although the examples are correct). My apologies. I'm going to clarify it right now.

You do not include the directories that you want to cd into. You include the parent directory.

From bash:
Quote:

This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command.
HTH

markush 11-11-2012 01:53 PM

Quote:

Originally Posted by sycamorex (Post 4827150)
Hi Marcus,

I think that the description entry in the wiki is misleading (although the examples are correct). My apologies. I'm going to clarify it right now.

You do not include the directories that you want to cd into. You include the parent directory.

From bash:


HTH

Thanks sycamorex for the quick reply,

I did this, I have for example several directories in /tmp/ named /tmp/build-ocaml, /tmp/build-trayer and so on (used for Slackbuilds). When I type
Code:

build-o[TAB]
the line is not expanded.

Markus

sycamorex 11-11-2012 02:02 PM

Weird. It works for me on 2 machines with stock Slackware 14 bash:
Code:

.bashrc
CDPATH=$CDPATH:/tmp/

Code:

echo $CDPATH
:/tmp/

Code:

ls /tmp
abc/  bcd/  cde/  def/  i3-sycamorex.cFpmeG/  plugtmp/


cd a[TAB] expands to abc.

Code:

cd abc/
/tmp/abc


markush 11-11-2012 02:06 PM

Is it possible that it has something to do with bash-completion? I don't have bash-completion installed.....

But otherwise referring to the manpage for bash, CDPATH should work like you described it.

It's really weird.

Markus

sycamorex 11-11-2012 02:23 PM

I think you've nailed it. It looks like the CDPATH variable itself does not provide TAB completion. It will correctly cd into a said directory as long as you remember its exact name, eg:

Code:

cd build-trayer[Enter]
but to get the TAB completion you do need to install bash-completion.

markush 11-11-2012 02:24 PM

Yup, that works.

Thanks for the clarification.

Markus


All times are GMT -5. The time now is 04:23 AM.