1 Star 0 Fork 1

李拓/Ubuntu-config

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
proxy-wsl2.sh 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
李拓 提交于 2022-03-10 12:26 +08:00 . 重命名为小写wsl2
#!/bin/sh
hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
wslip=$(hostname -I | awk '{print $1}')
port=7890
PROXY_HTTP="http://${hostip}:${port}"
set_proxy(){
export http_proxy="${PROXY_HTTP}"
export HTTP_PROXY="${PROXY_HTTP}"
export https_proxy="${PROXY_HTTP}"
export HTTPS_proxy="${PROXY_HTTP}"
export all_proxy="socks5://${hostip}:${port}"
git config --global http.proxy "${PROXY_HTTP}"
git config --global https.proxy "${PROXY_HTTP}"
}
set_proxy_git(){
git config --global http.proxy "${PROXY_HTTP}"
git config --global https.proxy "${PROXY_HTTP}"
}
unset_proxy(){
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY
git config --global --unset http.proxy
git config --global --unset https.proxy
}
test_setting(){
echo "Host ip:" ${hostip}
echo "WSL ip:" ${wslip}
echo "Current proxy:" $https_proxy
}
if [ "$1" = "set" ]
then
set_proxy
elif [ "$1" = "setgit" ]
then
set_proxy_git
elif [ "$1" = "unset" ]
then
unset_proxy
elif [ "$1" = "test" ]
then
test_setting
else
echo "Unsupported arguments."
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/lituo666/ubuntu-config.git
git@gitee.com:lituo666/ubuntu-config.git
lituo666
ubuntu-config
Ubuntu-config
master

搜索帮助