complete-alias
complete-alias copied to clipboard
Does this still work?
The instructions are confusing or I'm too dumb to figure them out or this doesn't work on Debian bullseye anymore running bash 5.1.4. I installed this with apt get bash-completion
I have an alias for docker called "dk".
I created file in home directory called complate_alias
with following:
complete -F _complete_alias dk
In a newly created file called .bash_completion
in my home dir, I have . /home/admin/complete_alias
. I also put the same in ~/.bashrc
.
I logged out and back into the shell. Resource all the files above. Still get:
dk <tab>-bash: completion: function
_complete_alias' not found`
Ok, I manually ran the following commands:
complete -F _complete_alias dk
complete -F _docker dk
And things started to work. I'm not entirely sure why, though.
One thing I'm noticing is that completion does not work with the alias until a completion has been run using the full command name at least once. 🤷🏽♂️
I don't have anything else in ~/.bash_completion
so I just saved the complete_alias file as ~/.bash_completion
Also I have this note in my /etc/bash.bashrc
which may or may not be relevant
# Debian doesn't have bash-completion by default so you need to apt install bash-completion and add the below
# also don't forget about https://github.com/cykerway/complete-alias
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
One thing I'm noticing is that completion does not work with the alias until a completion has been run using the full command name at least once. 🤷🏽♂️
for my use-case i do not need complete-alias, however i had this issue also & resolve it by writing
_completion_loader $program_name
complete -F _$program_name $alias_name
the completion function may be something other than _$program_name
depending on what it is. also, this works with anything, it is not limited to aliases
I created file in home directory called
complate_alias
with following:
complete -F _complete_alias dk
i made the same mistake. you need to COPY the complete_alias file from the repo an APPEND your completion command to it. the example in the read me walks you through it.