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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThat'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