Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Mac OS and sometimes some work need to be done using a proxy so I need to change my proxy setting frequently. But changing proxy setting in System Preferences is very messy.

Is there a way that I can change my proxy setting using command line? Use a shell command or some tools?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

EDIT: I am assuming you actually means Mac OS X, and not Mac OS..

You can use the commandline tool 'networksetup'

There is a manpage for it - networksetup(8)

man networksetup

You will find many options for proxy settings in there:

              [-setftpproxy networkservice domain portnumber authenticated username password]
              [-setftpproxystate networkservice on | off] [-getwebproxy networkservice]
              [-setwebproxy networkservice domain portnumber authenticated username  password]
              [-setwebproxystate networkservice on | off] [-getsecurewebproxy networkservice]
              [-setsecurewebproxy networkservice domain portnumber authenticated username password]
              [-setsecurewebproxystate networkservice on | off] [-getstreamingproxy networkservice]
              [-setstreamingproxy networkservice domain portnumber authenticated username password]
              [-setstreamingproxystate networkservice on | off] [-getgopherproxy networkservice]
              [-setgopherproxy networkservice domain portnumber authenticated username password]
              [-setgopherproxystate networkservice on | off] [-getsocksfirewallproxy networkservice]
              [-setsocksfirewallproxy networkservice domain portnumber authenticated username password]
              [-setsocksfirewallproxystate networkservice on | off] [-getproxybypassdomains networkservice]
              [-setproxybypassdomains networkservice domain1 [domain2] [...]] [-getpassiveftp networkservice]

Alternatively, if you just need to set the proxy for something like wget, or curl, then you can use the fairly universal 'http_proxy' and 'ftp_proxy' env variables.

Eg in bash:

export http_proxy=http://my.proxy.com:1234

Where '1234' is the port number.

cheers

sc.

share|improve this answer
    
thanks. networksetup is just what I want. –  flanker Aug 2 '11 at 3:26

Create a proxyless network environment: in the Network pane of System Preferences, click on the “Profile” drop down and select “Manage Profiles…”. Duplicate your standard settings (by clicking on the cog wheel button at the bottom of the list). Give the duplicated profile a unique name (“Proxyless”, say). Disable all proxies in the settings for that profile.

Assign a keyboard shortcut to your new profile: in the Keyboard pane of System Preferences, create a new Application shortcut for “All Applications”. Name it like your profile (i.e. “Proxyless”), add the shortcut.

The shortcut will be activated once your switch applications at least once (it won’t be active while you are still in System Preferences).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.