12

When I am running various commands on the command line in Ubuntu and use tab-completion for files. The only files I am given are ones which have the appropriate extension for the command I am running. For example..

xmms <tab><tab>

would list all the mp3's in the current directory and not any jpegs.

Most of the time this is quite useful. But if the file you want happens to have an incorrect extension, or the extension is valid but the tab completion doesn't think it is then it won't list the file or complete to it. So

  1. Is there a way to turn this feature off (just dumbly complete to any file regardless).
  2. How do you adjust the extensions that are valid for a particular command.

Thanks

Peter

1

5 Answers 5

1

comment out these lines in /etc/bash.bashrc (it may be in ~/.bashrc):

if [ -f /etc/bash_completion ]; then
 . /etc/bash_completion
fi
13

This is called "Programmable Completion" in bash. Use <tab> to attempt programmable completion, or use M-/ to attempt the default completion (usually files and directories). See also: http://spikeypillow.com/item/30/catid/4

3
  • Thanks for the official name (adding it to question title)
    – Vagnerr
    Commented Sep 23, 2009 at 16:10
  • How does this answer the question?
    – shantnu
    Commented Oct 8, 2014 at 13:21
  • @shantnu We were young. Mistakes were made.
    – user11088
    Commented Oct 8, 2014 at 18:19
8

The most elegant way to disable programmable completion should be to add:

shopt -u progcomp

to your .bashrc file. For more details, see the official documentation about the shopt command: http://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html

2

To change the completion behaviour, just edit /etc/bash_completion. Scroll down to where you find the list of programs and associated extensions. It should be pretty self-explanatory from there.

1

I put

complete -r

as last line of my .bashrc.
That discards all loaded completions and makes the shell 'dumb' again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .