views:

30

answers:

1

The default behavior for the [TAB] key in the shell is to automatically auto-complete or list the files in the current directory. How to override this behavior in the shell for some chosen applications?

Edit: This is not related to the application that is being used, rather, it's the shell environment that needs to be customized! (Thanks to Anders Abel for clearing this point)

+1  A: 

If you want to change the behaviour when creating the command line for starting the program, that's impossible from within the program. At that point your program is not yet started, so it's entirely up to the shell how to interpret [TAB] at that point.

Once your program is running you can of course handle [TAB] in whatever way you want, by using an appropriate API call.

Anders Abel
If you try to type `git ` and use [TAB] after the space, the list will show the available commands for `git` instead of the files. Other applications filter the accepted types (e.g. `gpdf` only lists *.pdf) instead of listing all files. How to do similar things?
banx
It is possible to customize the bash behaviour (didn't know until I loked it up now), see [this](http://aplawrence.com/Unix/customtab.html) blog entry. This is a customization to the bash environment, not to the program.
Anders Abel