mac 终端代理配置
banner 2023-03-06 11:06:00 Mac
# 检查终端类型
查看终端类型
echo $0
1
如果是 bash,配置 .bash_profile 文件,如果是 zsh,则配置 .zshrc 文件
# 编辑.bash_profile 或 .zshrc
# 开启代理
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export http_proxy="http://127.0.0.1:7890"
export https_proxy=$http_proxy
# export all_proxy=socks5://127.0.0.1:7890 # or this line
echo -e "\n"
echo -e "\033[32m已开启代理\033[0m" # 设置颜色
}
# 关闭代理
function proxy_off(){
unset http_proxy
unset https_proxy
unset all_proxy
echo -e "\n"
echo -e "已关闭代理"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
source .zshrc
1