function proxy() {
# 获取默认网关 IP
DEFAULT_GATEWAY=$(ip route show | grep default | awk '{print $3}')
# 默认代理服务器为默认网关 IP,默认端口为 7891
SERVER=${2:-$DEFAULT_GATEWAY}
PORT=${1:-"7891"}
export http_proxy="http://$SERVER:$PORT"
export https_proxy="http://$SERVER:$PORT"
echo "proxy is set to $SERVER:$PORT"
}
function unproxy() {
unset http_proxy
unset https_proxy
}
我常用的bash utils
最新推荐文章于 2025-04-30 16:11:32 发布