Setting environment variables on OS X

后端 未结 30 3232
你的背包
你的背包 2020-11-21 05:15

What is the proper way to modify environment variables like PATH in OS X?

I\'ve looked on Google a little bit and found three different files to edit:

30条回答
  •  感情败类
    2020-11-21 05:50

    To be concise and clear about what each file is intended for

    • ~/.profile is sourced every time Terminal.app is launched
    • ~/.bashrc is where "traditionally" all the export statements for Bash environment are set
    • /etc/paths is the main file in Mac OS that contains the list of default paths for building the PATH environment variable for all users
    • /etc/paths.d/ contains files that hold additional search paths

    Non-terminal programs don't inherit the system wide PATH and MANPATH variables that your terminal does! To set environment for all processes launched by a specific user, thus making environment variables available to Mac OS X GUI applications, those variables must be defined in your ~/.MacOSX/environment.plist (Apple Technical Q&A QA1067)

    Use the following command line to synchronize your environment.plist with /etc/paths:

    defaults write $HOME/.MacOSX/environment PATH "$(tr '\n' ':' 

提交回复
热议问题