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

Is it possible to have filetype-aware tab-completion in bash?

I.e. let's say there are two files in a directory, "foobar.txt" and "foobar.html", when I type "firefox foo" and then hit tab, bash would normally stop at "firefox foobar." because the normal, un-smart tab-completion is ambiguous. However preference could be given to "firefox foobar.html" because of the extension.

I think zsh implements something like this out of the box, but I want this in bash.

Is such a "smart" tab-completion possible in bash, and how?

share|improve this question

You should install/activate the bash-completion scripts (same name package on most Linux distro's I guess). That introduces smart tab-completion for each program for which a script is included (and you could even write your own).

Typically you can activate this globally by editing /etc/bash.bashrc and uncomment the lines after

# enable bash completion in interactive shells

Not sure it supports completion for the firefox command out of the box, though.

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.