Set EnvironmentVariables in MacOS
May 1, 2023
* Check Environment Variables
# list all environment variables
$ printenv
# list one specific variable PATH
$ echo $PATH
* Set Permanent Environment Variable
- Find or create ~/.bash_profile
# list exist .bash_profile
$ ls -la ~/.bash_profile
# create one if not exist
$ vim ~/.bash_profile
2. Open ~/.bash_profile and add the following line at the end of the file
# export [variable_name]=[variable_value]
$ export OPEN_AI_KEY="sk-"
$ PATH="~/bin:${PATH}"
$ export PATH
save any changes to ~/.bash_profile
3. Either restarting the terminate window or running
source ~/.bash_profile