1 Star 0 Fork 1

Falling Slowly/dotfiles

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
proxywsl 687 Bytes
一键复制 编辑 原始数据 按行查看 历史
Falling Slowly 提交于 2023-10-30 20:44 +08:00 . .
#!/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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangsl306/dotfiles.git
git@gitee.com:yangsl306/dotfiles.git
yangsl306
dotfiles
dotfiles
main

搜索帮助