How to access proxy settings in terminal

I want to use git in the terminal, but unfortunately I'm sometimes (but not always) behind a firewall that requires me to use a proxy server.


I've successfully set up environments for all these locations, including the proxy settings that are relevant in each context, but I'm unable to access them in the terminal (i.e. there's no HTTP_PROXY environment variable). My idea is to 'inherit' the system wide proxy settings in the terminal and use them to configure git.


Is there any way to access the proxy settings in the terminal.

OS X Mountain Lion (10.8.4)

Posted on Jul 1, 2013 2:24 AM

Reply
4 replies

Jul 1, 2013 5:48 AM in response to Franz_Woyzeck

In you home directory, create a file called .bash_profile (notice the leading dot)


nano .bash_profile


add to that file


export HTTP_PROXY="http://your.proxy.information:nnn"


Save the file


Restart the Terminal session.


Command line Git should work via the environment variable you just created.


NOTE: you will need to use


ls -a


to see the .bash_profile in a Terminal session, and because the leading dot makes it an invisible file, the Finder will not show it without some magic Finder Foo

Jul 1, 2013 6:26 AM in response to BobHarris

Thx for the answer, but that didn't solve the problem.

As my proxy settings change depending on the location that I'm using my MBA in I'd have to update the bash-profile every time that I change my place of working.

What I finally want to achieve is that the bash's proxy settings are inherited from the system's proxy settings, so whenever I select a new location in network settings my bash-proxy should change as well.

Jul 1, 2013 6:32 AM in response to Franz_Woyzeck

You could try creating a bash login script that uses one of the following uses of "networksetup" to list the current proxy, and then parse out the server address and apply it to the current terminal session:


networksetup -getftpproxy <servicename>

networksetup -getwebproxy <servicename>

networksetup -getsecurewebproxy <servicename>

networksetup -getstreamingproxy <servicename>

networksetup -getgopherproxy <servicename>

networksetup -getsocksfirewallproxy <servicename>


There may be other uses of the networksetup tool that can give you the specific proxy you are using, just look up "man networksetup" to see all the details and uses.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to access proxy settings in terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.