Setting environment variables on OS X

后端 未结 30 3158
你的背包
你的背包 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:44

    It's quite simple. Edit file .profile (vi, nano, Sublime Text or other text editor) file. You can found it at the ~/ directory (user directory) and set like this:

    export MY_VAR=[your value here]
    

    Example with Java home:

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/current
    

    Save it and return to the terminal.

    You can reload it with:

    source .profile
    

    Or close and open your terminal window.

提交回复
热议问题