I was hoping for a nice, concise way to ensure that my current pd alias was fully used (in case I need to tweak it later), though some of my attempts weren't concise at all. My last resort is to put it into a shell script and put that somewhere that sudo will be able to find. But aliases are soooo handy sometimes, so it is a last resort.

12 Answers
12

I don't know if it's the wisest thing to do on a production box but locally I use

alias sudo="sudo -E"

The -E (preserve environment) option will override the env_reset option in sudoers(5)). It is only available when either the matching command has the SETENV tag or the setenv option is set in sudoers(5).

Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
**A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.**

This is a great trick! For the curious, the explanation from the alias section in the bash manpage: A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded.
–
Russell DavisNov 23 '11 at 19:36

Wouldn't it be easier to simply hack out a script that includes your options, then place it somewhere in one of the folders that is the path for regular account and root? It really wouldn't take much of a script.

It actually has to be "$@" instead of $*, and that's part of the reason I generally try to avoid it. ;-) It works, it just wastes a bunch of disk space relative to what it contains.
–
TanktalusSep 1 '09 at 21:22