Skip to content

Wrapper for sudo so that you can use your shell functions under sudo

Notifications You must be signed in to change notification settings

wmertens/sudo.bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

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


About

Wrapper for sudo so that you can use your shell functions under sudo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages