If you make an alias in Bash, it's not trivial to get tab completion for it. This project aims to make that easy.
$ source alias-completion-bash k kubectl
$ eval "$(source alias-completion-bash k kubectl)"
usage: source alias-completion-bash <alias> <command>
outputs bash completion code for alias of command.
for example:
$ source alias-completion-bash k kubectl
to load the generated completion:
$ eval "$(source alias-completion-bash k kubectl)"
you could use it in ~/.bashrc, or use it in completion files.
Put alias-completion-bash
in a directory in your $PATH
.
For example:
# install ./alias-completion-bash /usr/local/bin/
Remove alias-completion-bash
from where you installed it.
For example:
# rm /usr/local/bin/alias-completion-bash
Getting tab completion for a Bash alias is not trivial. That is because Bash does not have a system for automatically doing tab completion for aliases; Bash considers the alias an entirely separate command.
As such, the usual approach is that you have to add the tab completion for your Bash alias yourself.
This project automates the step of finding the tab completion specification for the upstream command, and then repurposing it for use with your alias.