Created
August 26, 2009 21:44
-
-
Save capitalist/175871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function edithosts { | |
if [ -x "`which $EDITOR`" ] || [ -x "`which $1`" ] | |
then | |
if [ -x "`which $EDITOR`" ] | |
then | |
export TEMP_EDIT="`which $EDITOR`" | |
else | |
export TEMP_EDIT="`which $1`" | |
fi | |
echo "* Using ${TEMP_EDIT} as editor" | |
$TEMP_EDIT /etc/hosts && echo "* Successfully edited /etc/hosts" | |
dscacheutil -flushcache && echo "* Flushed local DNS cache" | |
else | |
echo "Usage: edithosts [editor]" | |
echo "(The editor is optional, and defaults to \$EDITOR)" | |
fi | |
unset TEMP_EDIT | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment