My system is Manjaro Linux based on Arch Linux, I use bash and bash-completion
.
It works perfectly when I type something as regular user (no sudo
)
$ rfkill <TAB><TAB>
block event help list unblock
but when I type it with sudo
$ sudo rfkill <TAB><TAB>
Display all 3811 possibilities? (y or n)
Obviously, it tries to complete sudo
command but I want it to complete rfkill
.
I know I can change this behavior by editing /usr/share/bash-completion/completions/sudo
file, but I have no idea how to say if second word is not a flag for sudo then use completion for next word.
Do you have?
UPD: I'm testing Ubuntu 16.04
in virtual machine and I see it works as expected. I'll check the difference between ubuntu's /usr/share/bash-completion/completions/sudo
file and mine, if any.
UPD2: There is some mirror (meaningless) difference between these files, anyway that didn't help. I have more ideas to test...
complete -cf sudo
in your.bashrc
and your.bash_profile
(this was my problem)? And are you sure you've sourced the completion file, i.e.. /usr/share/bash-completion/bash_completion
in your.bashrc
? – Contaminate