Open markeganfuller opened 10 years ago
Argcomplete completion works with sudo
when registering completion targets individually with register-python-argcomplete
(e.g., eval "$(register-python-argcomplete $(pwd)/my-awesome-script.py)"
).
Unfortunately, fixing it with global completion is tricky. In global completion, the function is not relying on bash to recognize the completion target by name like "my-awesome-script.py" or "git", instead it's given a name and must find out on its own whether it's a Python script that should be completed. This relies on complete -D
, which works fine in general, but when you type sudo <...><TAB>
, bash completion actually invokes _command_offset
, which appears to not be compatible with complete -D
at all.
So basically, if I understand correctly, the only way to make argcomplete global completion work with sudo
is to patch _command_offset
, which is part of the core bash-completion distribution, to be compatible with complete -D
.
The next step then is to open an issue upstream and start a patch against bash-completion.
Cool, thanks for looking into this. I'll leave the issue submission to you as you're better informed of the underlying issues.
Thanks,
When using sudo I get no autocompletion despite getting autocompletion for other commands (eg. git). Autocompletion works when running directly as root.
Tested on Ubuntu 12.04.3 LTS
Example Code