Skip to content
Back to top
View this page
Edit this page

# xompletions.sudo

Completer for `sudo`.

`sudo` is more than a transparent command wrapper: it has its own flag grammar, accepts `VAR=value` environment assignments before the command, and honours the POSIX `--` end-of-options sentinel. The generic command-token skipper in `xonsh.completers.commands` only knows how to strip the literal `sudo` token, which leaves `sudo -- foo`, `sudo -u root foo` and similar invocations without useful completions.

This module walks `ctx.args` past every token that belongs to `sudo`’s own prefix (flags, their values, `VAR=value` assignments, `--`) and then either offers command names (when the cursor sits on the inner command word) or re-enters the full completion pipeline with the inner command at `args[0]` so the inner command’s own completers (`man`, paths, `pip`’s xompletion, …) surface.

xompletions.sudo.xonsh_complete(ctx: CommandContext)

  Complete arguments to `sudo`.