3

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.

3

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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