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