Created
December 11, 2023 19:00
-
-
Save waldekmastykarz/7b9139c87911fe95c7aaeda08e88c9eb to your computer and use it in GitHub Desktop.
Toggle macOS proxy settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
arg1=$1 | |
# Get the list of network services | |
network_services=$(networksetup -listallnetworkservices | tail -n +2) | |
if [[ "$arg1" == "on" ]]; then | |
while IFS= read -r service; do | |
networksetup -setwebproxy "$service" 127.0.0.1 8000 | |
done <<<"$network_services" | |
elif [[ "$arg1" == "off" ]]; then | |
while IFS= read -r service; do | |
# Disable proxy on the network service | |
networksetup -setwebproxystate "$service" off | |
done <<<"$network_services" | |
else | |
echo "Set the argument to on or off." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment