Skip to content

Instantly share code, notes, and snippets.

@lsongdev
Created June 25, 2015 11:21
Show Gist options
  • Select an option

  • Save lsongdev/956a8310782caf469a06 to your computer and use it in GitHub Desktop.

Select an option

Save lsongdev/956a8310782caf469a06 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# put your hosts file into /etc/hosts.d/
#
# usage:
# chhost $your-host-name
# restore:
# chhost
HOSTD=/etc/hosts.d
SRC="$HOSTD/$1"
DEST="/etc/hosts"
sudo mkdir -p $HOSTD
if [ -z $1 ]; then
sudo mv $DEST{.bak,}
else
sudo mv $DEST{,.bak}
sudo cp $SRC $DEST
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment