代理
终端使用代理
- 使用clash等搭建代理后,终端不经设置并不会通过代理,而无论是Windows还是Linux,方法都是加入http_proxy,https_proxy或all_proxy环境变量。
windows
临时设置
1 | set http_proxy=http://127.0.0.1:7890 # =后的值可以加双引号,也可以不加 |
永久设置
- 终端启用代理的方法是那三个环境变量,因此永久设置就是手动去设置添加环境变量。
linux
临时设置
1 | export http_proxy=http://127.0.0.1:7890 # =后的值可以加双引号,也可以不加 |
永久设置
- 同样的,永久设置也是是将其写入环境变量,在Linux中是将上述内容添加到
/.bashrc或/.profile的末尾。
git
- 如果只是git需要使用代理,可以在git设置代理,原理相同:
1
2git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080' - 如果不想git全局使用代理,那只需要在需要代理的仓库输入去掉–global的命令即可:
1
2git config http.proxy 'socks5://127.0.0.1:1080'
git config https.proxy 'socks5://127.0.0.1:1080' - 若要取消git的代理设置:或
1
2git config --global --unset http.proxy
git config --global --unset https.proxy1
2git config --unset http.proxy
git config --unset https.proxy
wsl使用windows代理
首先,允许局域网连接代理。
1 | host_ip=$(ip route | awk '/default/ {print $3}') |