Skip to content

Instantly share code, notes, and snippets.

@sergioharo
Created April 5, 2013 17:47
Show Gist options
  • Save sergioharo/5321209 to your computer and use it in GitHub Desktop.
Save sergioharo/5321209 to your computer and use it in GitHub Desktop.
Bash script to programatically change the network location on a mac. This can be used for example to switch to a network location with a SOCKs proxy. The proxy can be started before the last exit.
#!/bin/bash
trap 'exit_with_reset; exit' SIGTERM SIGQUIT SIGINT SIGHUP
exit_with_reset()
{
echo "Resetting network location"
scselect "Automatic"
}
echo "Changing network location"
scselect "Name of my alternate location
sleep 10
echo "Do something else here if you want"
exit_with_reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment