wmertens/sudo.bash
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
This bash function will expand functions and aliases before running sudo.
It handles all sudo arguments. There is one extra argument, -x, which
expands arguments as you, not as root. This is needed in some corner cases.
To use it, copy it to ~/.sudo.bash (for example) and put
. ~/.sudo.bash
alias sudo=sudowrap
in your .bashrc (or copy the full code into your .bashrc).
Then, simply use sudo as you would before.
You can also wrap it in a script that changes your terminal color, like so:
function setclr() {
local t=0
SetTerminalStyle $1
shift
"$@"
t=$?
SetTerminalStyle default
return $t
}
alias sudo="setclr sudo sudowrap"
For that you need SetTerminalStyle, a program that interfaces with your terminal
to set its color. (OS X only, see http://code.google.com/p/setterminalstyle/ )