Question: I have several network locations set up on my laptop: Work, Home, etc. The work one(s) all have a proxy server set up, while the others don't. This works fine for OSX applications -- Safari, Mail, even Firefox and Thunderbird with the [System Proxy](http://systemproxy.mozdev.org/) plugin.

For terminal applications such as `git`, `svn`, `gem`, and `curl` I have the following in my `.bash_profile`:

```
export HTTP_PROXY='http://proxy.mycompany.com:80'
export http_proxy=$HTTP_PROXY

```

My question is this: is there some way to make the exported variable look up the value from my system's current location? I'd prefer it to be done dynamically (so if I change locations during a terminal session it will change), but I'd be happy with just one that set it when `.bash_profile` ran (meaning I'd have to start a new terminal session when I changed locations).

Thanks!

Answer: 
What version of Mac OS X? I'm not positive the tool is included with Mac OS X 10.4 or earlier.

`networksetup` should be what you're looking for, namely `sudo networksetup -getwebproxy NAME_OF_NETWORK_DEVICE` (eg. sudo networksetup -getwebproxy Airport)

The output comes out as so:

```
Enabled: Yes
Server: SERVER_ADDRESS
Port: 123
Authenticated Proxy Enabled: 0 for false, 1 for true

```

So you will need to convert the output to something usable.

A really crude example using awk a couple times (my awk skills are rather basic) would be:

```
sudo networksetup -getwebproxy Airport | awk {'print $2'} | awk {'getline l2; getline l3; print "http://"l2":"l3'} | head -n 1

```

Results in an output `http://SERVER_ADDRESS:123`
I just did this `scutil --proxy` and copied the `HTTPPort` parameters and the `HTTPProxy` parameters.
Then I did this `export ALL_PROXY=HTTPPort:HTTPProxy` where you will replace the `HTTPPort` and `HTTPProxy` with your parameters.
Then finally, I did this `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
Now you're good to go.