Consider this one-liner to activate bash completion for foobar
:
complete -F _known_hosts foobar
This shows a list of completion options for
> foobar <TAB> <TAB>
but not for
> $(foobar <TAB> <TAB>
or
> `foobar <TAB> <TAB>
I think it makes a lot of sense to have tab completion for expressions that are inside backticks or $(). How can I make this work?
Bash completion is a bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key. This will help you when writing the bash command in terminal.
You can use the complete command with the -p option to get a list of all or specific completions.
Bash completion is a functionality through which Bash helps users type their commands more quickly and easily. It does this by presenting possible options when users press the Tab key while typing a command.
Try these:
Esc+/ (to complete the filename i.e. you have entered some characters
Ctrl+x+/ (to list possible filenames - do note; there are 2 +)
(I was searching for an answer to this question for a long time; then got this from bash man page :-))
Bash completion inside back ticks or $() is called "command substitution".
So it looks similar to a few other questions:
https://unix.stackexchange.com/questions/152328/bash-tab-completion-fails-inside-of-command-substitution
https://askubuntu.com/questions/571544/bash-tab-completion-bash-unexpected-eof-while-looking-for-matching-bash/576983#576983
https://unix.stackexchange.com/questions/152328/bash-tab-completion-fails-inside-of-command-substitution
For Debian-based linux operating systems like Ubuntu, the problem is a known bug from the bash-completion application: /usr/share/bash-completion/completions
You can report an issue here:
https://github.com/scop/bash-completion/issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With