Search code examples
bashcommand-linebash-completion

Override bash completion for every command


I have a (possibly ill-advised) idea for improving tab completion based on the command history. Ideally, I'd want to apply this to every command in the terminal.

Basically I'm looking for something like:

complete -F _my_function *

where the glob actually works.

Is this at all possible, or would I have to set it manually for every command I use?


Solution

  • complete -D defines the "default" completion procedure, for all commands for which no specific completion has been set. If you want the default to apply to all commands, just don't set any specific completions. If you want to remove a completion, use complete -r command (or complete -r to erase all of them).

    Also see complete -E.

    For details, see the Bash manual.