Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my Fedora 19 system tab completion doesn't work for bash scripts when I have a sh at the beginning of the command line unless the script filename ends with a .sh.

That is, if I type:

$ sh file<tab>

And the current directory contains:

filename completion doesn't work.

But if the current directory contains:

Completion works.

Completion works for everything else, so I suspect that there is a custom completer for commands that begin with sh and it is looking for files that end .sh.

Is there an easy way to fix this? I want to fix it for my user, not for all users, because I don't want to modify the operating system.

share|improve this question
As @AlexanderPoteriachin pointed out, if you type filename yourself and the file is named filename there nothing more to complete. Do you mean you type e.g. only filen and [TAB] is not working? – mpy Jul 17 '13 at 11:36
up vote 7 down vote accepted

The most basic commands to customize your completions in bash are:

  • To only complete .sh files after (G stands for globbing):

    complete -G '*.sh' sh

    Probably this is somewhere in your (system wide) config. (You can check with complete -pr which prints all definitions)

  • To complete any filename after sh just issue

    complete -A file sh

    -A takes much more possible actions (here: file), please check out the description of the complete builtin in man bashbuiltins for much more options.

For a permanent fix of that behavior, put the last command also to your ~/.bashrc.

share|improve this answer
Yep. That did the trick. Thanks! – vy32 Jul 17 '13 at 21:54

No, there should be anything custom. Haven't seen on anything like that on any Linux version. The tab completion works as expected.

By the way, what is the point

$ sh filename<tab>

of that anyway if you have "filename" in your directory?

Maybe you're confused a little bit, as if you have two similar filenames in a directory, the completion only goes until the characters are the same and then it shows all available options.

share|improve this answer

Your Answer


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.