创建proxy.sh文件
#!/bin/bash
hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
https_proxy="http://${hostip}:7890"
http_proxy="http://${hostip}:7890"
function set_proxy() {
export http_proxy="${http_proxy}"
export https_proxy="${https_proxy}"
echo "env http/https proxy set."
}
function unset_proxy(){
unset http_proxy
unset https_proxy
echo "env proxy unset"
}
if [ "$1" = "set" ]; then
set_proxy
elif [ "$1" = "unset" ]; then
unset_proxy
else
set_proxy
fi
保存之后chmod +x proxy.sh
使用说明
- windows开启clash
- wsl运行
source proxy.sh [set]开启 - wsl运行
source proxy.sh unset关闭