代码拉取完成,页面将自动刷新
#!/bin/bash
shellrc=~/.zshrc
if [[ $(echo $SHELL) =~ bash ]]; then
shellrc=~/.bashrc
fi
# current proxy IP
proxy_rc_file=$(grep 'export http_proxy=' ${shellrc} | awk -F'[/:]' '{print $4}')
# WSL2 proxy IP
proxy_wsl=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
if [[ ${proxy_wsl} != ${proxy_rc_file} ]]; then
sed -i "s/${proxy_rc_file}/${proxy_wsl}/g" ${shellrc}
echo "the proxy IP in ~/$(basename ${shellrc}) is: ${proxy_rc_file}."
echo "the proxy IP in WSL2 is: ${proxy_wsl}"
echo "WSL2 proxy IP is updated!"
else
echo "the proxy IP in ~/$(basename ${shellrc}) and WSL2 are same, is: ${proxy_rc_file}."
echo "It's no need to update!"
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。