Wrapper for sudo so that you can use your shell functions under sudo
Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
sudo.bash

README

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/ )