OS X Safari: Toggle Socks Proxy from command line
To turn on SOCKS proxy for the network service called Wi-Fi, run

networksetup -setsocksfirewallproxystate Wi-Fi on


Replace ‘Wi-Fi’ with the name of your network service.
Replace ‘on’ with ‘off’ to turn off the proxy.