简体   繁体   中英

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

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 "." 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

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:

setenv var.Property someValue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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