Skip to content

Instantly share code, notes, and snippets.

@luigi
Created August 3, 2009 20:53
Show Gist options
  • Save luigi/160825 to your computer and use it in GitHub Desktop.
Save luigi/160825 to your computer and use it in GitHub Desktop.
# For Mac OS X users who don't want to manually add entries into /etc/hosts
# Stick these functions in your .bash_login or equivalent
#
# From the command line:
# $ add_localhost foo
# will create foo.local
#
# No error checking, so don't mess up...
function add_localhost {
sudo dscl localhost -create /Local/Default/Hosts/$1.local IPAddress 127.0.0.1
}
function delete_localhost {
sudo dscl localhost -delete /Local/Default/Hosts/$1.local
}
function list_localhosts {
sudo dscl localhost -list /Local/Default/Hosts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment