2

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?

0

1 Answer 1

3

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.

You must log in to answer this question.