This is in my
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
Why is that?
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: