Skip to content

Instantly share code, notes, and snippets.

Last active October 25, 2022 18:31
What would you like to do?
OS X shell script for routing all traffic through tor. Requires tor to be installed (brew install tor). Taken from, modified from To stop using tor just terminate this script with Ctrl C
#!/usr/bin/env bash
# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Let's roll
sudo networksetup -setsocksfirewallproxy $INTERFACE 9050 off
sudo networksetup -setsocksfirewallproxystate $INTERFACE on
sudo networksetup -setsocksfirewallproxystate $INTERFACE off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment