Disable extension filtering in bash-completion

Sun, 19 Nov 2023

Disable extension filtering in bash-completion

Quick tip,

I’m a fan of the bash-completion collection except for one thing, the file extension based filtering that limits, for example, file name completion to .pdf files for various PDF readers. The bash-completion people do a great job of maintaining the filters - for instance, the “unzip” filter will expand extensions like .epub and .odt, but I often encounter or work with files with missing, incorrect, or custom file extensions.

I had been laboriously restoring the default completion for the various programs I’d had problems with (E.g., complete -o default -o bashdefault unzip), but finally had enough and submitted a feature request. Turns out the solution is easy and I can fully disable extension-based filtering for all commands without having to continually update my list of exceptions by adding the following to my .bashrc (after loading bash-completion):

# Disable bash-completion extension-based filtering
declare -gA _comp_xspecs=() _xspecs=()

Set Zero

Home

2024

2023

2022

2021

2020