1

I'm new to using Mac OS X. From my understanding, it uses Linux under the covers. I have a need to add an environment variable. Currently, whenever I start a terminal window, I've been executing export MY_ENVIRONMENT_VARIABLE=enabled. I would like to automatically do this, system wide, when the machine starts.

How do I do that on Mac OS X? I tried adding the above line to ~/.bashrc via nano without any luck. How should I set this environment variable?

Thank you!

1
  • 2
    BSD, not Linux.
    – JdeBP
    May 1, 2015 at 16:08

1 Answer 1

2

To affect system-wide settings, you probably should add:

export MY_ENVIRONMENT_VARIABLE=enabled

to /etc/profile or /etc/bashrc (the latter is sourced from /etc/profile).

OSX uses bash by default for its /bin/sh. However, it does not use "Linux under the covers", but rather is mostly BSD (with some exceptions such as bash).

Here are some related questions/discussion (which suggest OSX-specific places to modify instead, e.g., environment.plist):

2
  • What do you mean by 'modify /etc/bashrc'. What to put there in modifications?? Nov 29, 2015 at 16:52
  • 1
    @igor You add export MY_ENVIRONMENT_VARIABLE=enabled to /etc/profile or /etc/bashrc
    – wisbucky
    Apr 20, 2016 at 18:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .