Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to complete alias after alias of sudo?



Peter Stephenson wrote on Fri, 02 Jun 2017 09:46 +0100:
> Standard case: "sudo -i" runs the command in a shell, so it will use
> whatever shell environment has been provided in the sudo environment.
> In general we don't know what that is, and quite like using the local
> environment for completing functions and aliases isn't right.  But
> without much more digging this may be the best solution.

There's no easy way for us to complete aliases for root; we don't even
know what shell sudo will run its command under.

However, we could add a layer of indirection so people can fill this in
their own configs:

[[[
_arguments ... '(-)1:command:_sudo_command'

_sudo_command() {
  if -i or -s passed:
    _sudo_aliases
  else
    _command_names
  fi
}

_sudo_aliases() {
  _command_names -e
}
]]]

... and document that _sudo_aliases is intended to be
overwritten/redefined by a user's .zshrc file.



Messages sorted by: Reverse Date, Date, Thread, Author