简体   繁体   English

如何在OSX Yosemite上设置环境变量?

[英]How to set an environment variable on OSX Yosemite?

I am trying to set a global/system variable in my computer, I am using Yosemite. 我正在尝试在计算机中设置全局/系统变量,我正在使用优胜美地。

I opened my ~/.profile (that is the default profile file configuration) , and I added this 我打开〜/ .profile(这是默认的配置文件配置),并添加了它

setenv var.Property someValue

but it didnt work, 但这没用

Neither this way 都不是这样

export var.Property = someValue

everytime I do echo $var.Property I get as result "Property" I think the "." 每当我回显$ var.Property时,我都会得到结果“ Property”,我认为是“。”。 may be interfering with this. 可能会干扰这一点。 I do need to have it this format, but unfortunately, is not working. 我确实需要这种格式,但不幸的是,它无法正常工作。

Any idea how to do this? 任何想法如何做到这一点?

You will get a different environment based on if you start via command line vs double clicking ... if you start with the command line you should get whatever is in env and if you start by clicking it then you will get whatever is in launchtl's env... so for that to change you use 您将获得不同的环境,具体取决于您是通过命令行启动还是双击...如果您从命令行启动,则应该获取env ,如果您通过单击它启动,那么您将获得launchtl的env中的所有内容...为了改变你使用

launchctl setenv DOG cat

Edit: 编辑:

it seems as though you can't have an env var with a key that has a period in it... this works fine in csh: 似乎您无法使用带有句点的键来拥有一个env var ...在csh中可以正常工作:

setenv var.Property someValue

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

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