This is in my .bashrc:alias p='sudo apt-get'; complete -F _apt_get pI'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?
Bash autocompletion for an alias
bash;autocomplete;bashrc
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