2

This is in my .bashrc:

alias p='sudo apt-get'; complete -F _apt_get p

I've found the autocompletion only works if I've used autocompletion for apt-get at least once before trying to use it with the p alias.

Why is that?

1

That's because completions are loaded dynamically by the "bash-completions" library. This works because the completion specifications are kept "in a file corresponding to the name of the command" (man bash).

Add this to your .bashrc:

_completion_loader apt-get

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.