Skip to content

Instantly share code, notes, and snippets.

@arastu
Last active May 7, 2017 16:43
Show Gist options
  • Save arastu/1a54971c901ff01d372aae1e01e6a88b to your computer and use it in GitHub Desktop.
Save arastu/1a54971c901ff01d372aae1e01e6a88b to your computer and use it in GitHub Desktop.
Shell function to set, on or off http and https proxy
# add this function to .zshrc or .bashrc
# Example:
# Set http and https proxy:
# $ macsetproxy 127.0.0.1 8118
#
# Turn http and https proxy off
# $ macoffproxy
#
# Turn http and https proxy on
# $ maconproxy
#
# If you want set, on or off proxy in other interface in your mac
# change "Wi-Fi" to appropriate interface
function macsetproxy() {
sudo networksetup -setwebproxy "Wi-Fi" $1 $2
sudo networksetup -setsecurewebproxy "Wi-Fi" $1 $2
}
function maconproxy() {
sudo networksetup -setwebproxystate "Wi-Fi" on
sudo networksetup -setsecurewebproxystate "Wi-Fi" on
}
function macoffproxy() {
sudo networksetup -setwebproxystate "Wi-Fi" off
sudo networksetup -setsecurewebproxystate "Wi-Fi" off
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment