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

Re: using command aliases with sudo



On Wed, May 28, 2003 at 02:04:44AM -0500, Eric Mangold wrote:
> I'm thinking of writing an extension to zsh that makes aliases work with sudo.

You just need an alias with a trailing space, like this:

    alias sudo='command sudo '

That will cause zsh to expand your command aliases after a "sudo"
command.  Unfortunately, it's not perfect because it does not handle
sudo options properly.  I.e., this won't work (where "agi" is your
aliased command):

    sudo -u bin agi

but this will work:

    sudo agi

You can work around the problem for often-used users like this:

    alias sudobin='command sudo -u bin '

..wayne..



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