.bash_profile and how to permenantly set environment variables on Mac

.bash_profile file

If you’re not familiar with a .bash_profile file, this is a startup file that is read whenever you open a new Terminal window. It’s a special configuration file, and it needs to be placed in your home directory. For instance, on my MacBook Pro, this file is located as /Users/bowen.li/.bash_profile.

My .bash_profile file

As you can see from my sample file shown below, the .bash_profile file can contain any legal Unix command, including Unix alias definitions, Unix export and PATH statements, and other commands to set up your Bash prompt.

1
2
3
4
5
6
7
8
9
10
11
# aliases
alias cd..="cd .."

# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH


export SNOWFLAKE_USER_ENV="xxx"
export SNOWFLAKE_PASSWORD_ENV="xxxx"

How to permenantly set environment variables on Mac

1
echo $YOUR_KEY

it prints current path value.

Then do

1
vim ~/.bash_profile

and write

1
export YOUR_KEY=YOUR_VALUE

then do

1
source ~/.bash_profile

this will execute it and add the path

then again check with

1
echo $YOUR_KEY