mac中的Shell Path在哪里? .bash_profile不能正常工作

时间:2015-12-30 20:40:21

标签: macos terminal

当我使用时: nano .bash_profile

终端告诉我:

export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH


# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export PATH="/Applications/MAMP/Library/lib"
export PATH="/Applications/MAMP/Library/bin"
#XAMPP
#export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
#export PATH="/Applications/XAMPP/xamppfiles/lib:$PATH"

但是当我打开一个新的终端只显示。 echo $ PATH打印。

/Applications/MAMP/Library/bin

问题是当我执行命令时终端返回:

command not found 

我需要执行此命令才能使终端正常运行

export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH

和echo $ PATH打印。

/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:/Applications/MAMP/Library/bin

如何打开和编辑正确的shell PATH?

1 个答案:

答案 0 :(得分:0)

每次导出时都会覆盖PATH变量。你的.bash_profile应该是

export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin
export PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH="/Applications/MAMP/Library/lib:$PATH"
export PATH="/Applications/MAMP/Library/bin:$PATH"

这样您的当前路径就会添加到新路径变量的末尾