Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In SLES 10.1 when you press the Tab key without typing anything in a directory you get a list of the directory. What is the setting for this so that I may set it in CentOS 5.4?

share|improve this question
    
I assume you are using bash? It matters. TCSH is different. –  kmarsh Jul 21 '09 at 20:20
    
Also, are you a vi mode user or emacs mode user? –  kmarsh Jul 21 '09 at 20:25
    
Are you looking for filename completion (like after ls) or for the ls/echo * functionality from the Tab key at a bare prompt? On Red Hat (parent of CentOS), hitting Tab twice from a prompt will get you all possible executables in your Path, including directories marked executable. –  kmarsh Jul 21 '09 at 21:32
add comment

3 Answers

up vote 3 down vote accepted

For bash:

set disable-completion Off

share|improve this answer
add comment

You need to have the bash-completion modules installed. Some distributions bundle them with bash, others package them seperately. Once they're installed, you need to activate them. In Ubuntu/Debian, that's done by sourcing /etc/bash_completion in your .bash{rc,_profile}.

For CentOS 5, the process is documented here:

http://thedaneshproject.com/posts/bash-completion-on-centos-5/

share|improve this answer
    
I believe this is for completion of command-line arguments to commands, not filename completion. I have found the debian implementation of argument completion to be wanting. –  kmarsh Jul 21 '09 at 21:30
    
As near as I can recall from writing programmable completion modules in the past, bash does not differentiate between the two. The quality of the argument completion just depends on the quality of the code for the command in question... –  Insyte Jul 21 '09 at 21:44
    
D'oh... disregard. The word completion performed before a command has been entered appears to be performed by the readline library. Once a command has been entered, bash switches to programmable completion. –  Insyte Jul 21 '09 at 21:48
add comment

I'm guessing you're referring to SUSE listing everything in the current directory rather than showing you all the executable commands in your path, as bash by default has tab complete turned on and I've never heard of a distribution disabling it as standard.

Bash has the complete builtin command that allows you to customise the tab completion. There are several projects which provide some decent completions for many common tools. It's possible that this is what SUSE uses. You should be able to find the exact function that they use by looking through the bash startup files (which you can find listed in the very comprehensive (read: long) man page). One of those will source a collection of complete functions, one of which will do what you want.

I do have to ask the wisdom of tab completing to the contents of the current directory. I suppose showing you a list of 3-4000 programs isn't the most useful feature. If you have something in the command line already, does it tab complete the executable on your path or does it complete to something in the current directory?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.