在macOS系统中编辑PATH变量,可以通过修改.bash_profile
或.zshrc
文件来实现。以下是具体步骤:
echo $SHELL
如果输出结果为/bin/bash
,则使用步骤3;如果输出结果为/bin/zsh
,则使用步骤4。
.bash_profile
文件:
open -a TextEdit ~/.bash_profile
如果文件不存在,上述命令将创建一个新的文件。
.zshrc
文件:
open -a TextEdit ~/.zshrc
如果文件不存在,上述命令将创建一个新的文件。
export PATH="/your/new/path:$PATH"
其中,/your/new/path
是你要添加的路径。
source ~/.bash_profile
或
source ~/.zshrc
现在,你已经成功地在macOS系统中编辑了PATH变量。
领取专属 10元无门槛券
手把手带您无忧上云