ProxyConf is a free and open source command-line application that allows you to configure your proxies in System Preferences, and it takes care of grabbing these values and exporting them as environment variables. The upshot of this is, your command-line apps will use the same proxy settings as your GUI apps.