Details of the proxy address which is being used by Mac
Either get ProxyConf, which does exactly this.

Or retrieve the web proxy with networksetup -getwebproxy Ethernet (replace Ethernet with the one you're using from networksetup -listallnetworkservices), then format the output into HTTP_PROXY format:

$ networksetup -getwebproxy Ethernet | awk '/Server:/ {host=$2} /Port: / {port=$2} END { printf "http://%s:%s", host, port}'
http://127.0.0.1:8228


If your network services (Ethernet, Wifi, etc.) vary or you use multiple at the same time, you may need to get a little more elaborate to figure out which one is being used. man networksetup and man ifconfig should have everything you need if you want to go there.

Formerly there was also scselect, but networksetup incorporates all of it's functionality.