I got tired of manually setting http_proxy & ftp_proxy on my job computer that I sometimes use at work (proxy needed) or at home (no proxy needed) so I came up with this dirty, but workable pice of bash script.
The ip x.x.x.x in the script below is the office IP (assigned by DHCP, but always resolved to static IP address based on my MAC)
#Set proxy if in office ip=$(/sbin/ifconfig eth0 | grep -e".*inet addr.*" | sed -e "s/.*inet addr://g" | sed -e"s/ .*//g") if [ $ip = "x.x.x.x" ] then http_proxy="http://office.proxy.com:80" ftp_proxy="http://office.proxy.com:80" export http_proxy export ftp_proxy fi
The above is part of a bigger script (myVariables.sh) that set other stuff as well, and this script is called from my bash profile (~/.bashrc) so every time I create a bash shell I get this set.