Modify bash autocomplete rule to exclude particular file names

To exclude uninteresting filenames or extensions from bash completion, add this line to your .bashrc file:

FIGNORE=".log:.dvi:.pdf:"

You can see the current configuration with

complete -p vi
complete -o bashdefault -o default -o filenames -o nospace -F _exp_ vi

and the definition of the used shell function with

type _exp_

There is a complete feature / option -X which allows to filter the results. The problem is that this applies only to to complete actions. It does not apply to the -o default results (I don't know about -o bashdefault).

You can change the compspec:

complete -d -f -o filenames -o nospace -F _exp_ -X '@(config.log|config.doc)' vi

Unfortulately

  1. you can have only one -X in the complete call (former ones are overwritten)

  2. you need shopt -s extglob for the above to work; otherwise you are limited to a single name or pattern ("*.log")