Skip to content

Instantly share code, notes, and snippets.

@MuntashirAkon
Last active Nov 2, 2019
Embed
What would you like to do?
Guide to enable macOS Terminal to respect system proxy

Copy and paste the code below at the beginning of ~/.bash_profile.

export http_proxy=`scutil --proxy | awk '\
  /HTTPEnable/ { enabled = $3; } \
  /HTTPProxy/ { server = $3; } \
  /HTTPPort/ { port = $3; } \
  END { if (enabled == "1") { print "http://" server ":" port; } }'`
export HTTP_PROXY="${http_proxy}"
export https_proxy=`scutil --proxy | awk '\
  /HTTPSEnable/ { enabled = $3; } \
  /HTTPSProxy/ { server = $3; } \
  /HTTPSPort/ { port = $3; } \
  END { if (enabled == "1") { print "http://" server ":" port; } }'`
export HTTPS_PROXY="${https_proxy}"

Source: https://dmorgan.info/posts/mac-network-proxy-terminal/

Note: If you're using Tor, SOCKS proxy isn't supported by Terminal, so add HTTPTunnelPort 9080 at /usr/local/etc/tor/torrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment