views:

496

answers:

2

I have a folder 'test' which contains another folder 'test2'

When I type 'cd te[tab]' it auto-completes to 'cd test/'

How do I make it autocomplete to 'cd test/test2/', without hitting tab again?

To clarify: test is the only folder/file in the folder test. I want this to work recursively so if there is a folder/with/a/lot/of/single/files/or/folders/in/it

A: 

It is hard for bash to understand either you want to jump to test or to test/test. So I believe there is no standard settings.

But you can always alias commands for particular cases like

alias cdtest="cd test/test"
Mykola Golubyev
+2  A: 

Bash supports programmable auto completion (at least since version 3.0). There is some documentation in the bash manual on

http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion

It might also be a good idea to look at existing scripts to get an idea how to really make use of that feature. Debian for example has a /etc/bash_completion file with completion scripts for various programms. I'm sure other distributions have something similar

Caotic