I recently installed bash-completion (via homebrew). It now omits files in the completion list that I want it to show, and completely omits valid options, such as this:

[alex@mbp foo]$ ls
bar.csv foo.csv
[alex@mbp foo]$ sh ../dosomething.sh fo<TAB>
((nothing shown))

As a heavy command line user, this is extremely annoying. Can anyone tell me how to disable this behaviour? I could not find anything useful in the documentation or Google.

The bash-completion FAQ says:

Q. The bash completion code inhibits some commands from completing on files with extensions that are legitimate in my environment. Do I have to disable completion for that command in order to complete on the files that I need to?

A. No. Use M-/ to (in the words of the bash man page) attempt file name completion on the text to the left of the cursor. This will circumvent any file type restrictions put in place by the bash completion code.

But this is not an acceptable solution for me - I want "TAB" to show all files/directories regardless of whether the extension is valid for the file or not (that's how it has worked well for me for the last 20 years).

How can I achieve this?

I'd prefer a .bashrc/.bash_profile setting over deleting global completion scripts. Here is how I currently include the bash-completion (it's just a stock homebrew installation):

[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

Update: I've seen this Bash filename tab completion but it's not quite what I want, as it requires too much manual work for every possible file extension on earth/my system.


2 Answers 2


The accepted answer still doesn't really fix the problem as it breaks command completion (ie, "pyt+TAB" to get python, etc) since that's not included in complete-filename.

complete -o default python

This won't fix the issue for all commands (only "python" in this example), but it will fix it for particular commands that are grossly misbehaving. Unfortunately there doesn't appear to be a clean way to set "default" (ie, Readline's default) on everything, it must be done for each and every command you might use. Or use the .inputrc workaround above.


Also vexed by this, so I read the bash manual. I believe the desired behavior can be achieve with this as your ~/.inputrc file:

TAB: complete-filename
M-/: complete

Regular completion, with the full suite of rules, is mapped to Meta-/ and filename-only completion maps to TAB.

  • finally the correct answer! Commented Apr 21, 2023 at 6:44

You must log in to answer this question.

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