1、获取端口
在代理工具中获取其开放的 HTTP 端口,比如这里使用的端口是 1088
2、配置代理
bash 终端
bash 是 macOS Mojave 及更低版本中的默认 Shell 终端
a) 打开终端文件
- 方法一:使用命令行
vi ~/.bash_profile
- 方法二:直接在Finder中手动打开,
.bash_profile
文件默认隐藏,在user
的主目录中键盘输入快捷键command + shift + .
开启隐藏文件,如果没有.bash_profile
文件,我们可以手动创建,文件目录在user
的主目录下。
b) 配置内容
在.bash_profile
文件内容最后新起一行,输入以下内容并【保存】。
其中端口号127.0.0.1:1088
根据自己的工具开放端口配置
proxy
和 proxyOff
是执行代理开关的便捷终端命令
alias proxy='export http_proxy=127.0.0.1:1088;export https_proxy=$http_proxy'
alias proxyOff='unset http_proxy;unset https_proxy'
c) 配置内容
Terminal终端执行配置文件生效命令
source ~/.bash_profile
zsh 终端
zsh 是 macOS Catalina 及更高版本中的默认 Shell 终端