Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.