昨天提了个问题,关于如何代理部份命令: https://www.v2ex.com/t/432942
受到启发于是 .zshrc
里写了这段脚本用来给命令单独设置代理:
function set_proxy {
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
}
function clr_proxy {
export http_proxy=
export https_proxy=
}
function proxy() {
if [[ $* ]]
then
set_proxy && echo "[proxy] set"
$*
clr_proxy && echo "[proxy] clear"
else
echo "Set proxy for a specific command."
fi
}
SET_PROXY_FOR=('brew' 'git')
for cmd in $SET_PROXY_FOR
do
alias $cmd="proxy $cmd"
done
试了下挺好用的。貌似还没看到有人这么做过,不知道有没有啥弊端。
1
missdeer 2018-02-27 11:02:59 +08:00
网关 xx 是王道
|