写了一个smart_switcher,可以自动判别并设置各种代理,特别适合office有代理、家里无代理各种切换的情况。
原理是根据《如何为 Git 设置代理?》来的,不过简化到超简单,只需设置你的网关IP和Port即可。
ReadMe在此。。。
smart_switcher
A auto-detect proxy switcher fot http, https, ftp, rsync, ssh, git protocols.
Overview
A smart proxy switcher wrapper, supports http, https, ftp, rsync, ssh(connect depanded), git(connect depanded) protocols. It can automatically detect your network environment and set proxy for you.
If you usually switch the network environment (maybe home with no-proxy and workplace with proxy), it may help you a lot.
Tested in zsh and bash.
Screenshot
Install
Simply source it in your .zshrc, or any shell script resource file like this:
source /path/to/smart_switcher.sh
and, make sure set your proxy_server/gateway in smart_switcher.sh.
Usage
Normally, it antomatically executes when you login in.
smart_switcher supports cecho, who will bring some colors for you.
connect is required if proxy is supported in ssh and git. You can install it easily in path /usr/bin/connect.