简体   繁体   English

如何在Mac上设置自定义环境变量?

[英]How to set custom Environment variable on Mac?

I have a requirement where I need to set a custom environment variable called CLUSTER_ENV = '@fooURL' The steps I have followed are: 我有一个需要设置自定义环境变量CLUSTER_ENV = '@fooURL'的要求,我遵循的步骤是:

  1. Open terminal, open bash_profile and save CLUSTER_ENV='@foo' . 打开终端,打开bash_profile并保存CLUSTER_ENV='@foo' When I do echo $CLUSTER_ENV , I get blank output. 当我echo $CLUSTER_ENV ,我得到空白输出。
  2. I did the same thing in the bashrc file and in this case, the $CLUSTER_ENV shows the value only when I run it in the same terminal window. 我在bashrc文件中做了同样的事情,在这种情况下, $CLUSTER_ENV仅在我在同一终端窗口中运行它时才显示该值。

Which is the best or recommended way to permanently set the environment variable on a Mac? 在Mac上永久设置环境变量的最佳或推荐方法是哪种? Im running El Capitan. 我正在运行El Capitan。

I have gone through these links for reference: 我已经通过以下链接进行参考:

http://osxdaily.com/2015/07/28/set-enviornment-variables-mac-os-x/ http://osxdaily.com/2015/07/28/set-enviornment-variables-mac-os-x/

Mac OS X 10.9 - setting permanent environment variables Mac OS X 10.9-设置永久环境变量

就像您通常在任何Linux发行版上所做的那样:导出CLUSTER_ENV = my.url.com,必须将其添加到〜/ .bash_profile中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM