Skip to content

Instantly share code, notes, and snippets.

@536
Last active April 27, 2024 12:05
Show Gist options
  • Save 536/9bd1dd5de0e4d7badd08327a2d3bd1a5 to your computer and use it in GitHub Desktop.
Save 536/9bd1dd5de0e4d7badd08327a2d3bd1a5 to your computer and use it in GitHub Desktop.
Using windows proxy in WSL
function set_proxy() {
# 自动获取宿主 Windows 的 IP 地址
proxy_server=`cat /etc/resolv.conf|grep nameserver|awk '{print $2}'`
# 改成你的 http_proxy(局域网)端口号
proxy_port=10809
export http_proxy=http://$proxy_server:$proxy_port
export HTTP_PROXY=$http_proxy
export https_proxy=$http_proxy
export HTTPS_PROXY=$http_proxy
git config http.proxy $HTTP_PROXY
git config https.proxy $HTTPS_PROXY
}
function unset_proxy() {
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
git config --unset http.proxy
git config --unset https.proxy
}
function proxy() {
echo "http_proxy:" $http_proxy
echo "HTTP_PROXY:" $HTTP_PROXY
echo "https_proxy:" $https_proxy
echo "HTTPS_PROXY:" $HTTPS_PROXY
echo "git config http.proxy:" $(git config http.proxy)
echo "git config https.proxy:" $(git config https.proxy)
curl -s "https://ip.jackjyq.com" | grep -E -i "ip:|country:"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment