From the shell:
open /Applications/TextEdit.app .bash_profile
Edit the file and save it.
You’ll add lines like:
export FOO=value
Close your shell windows and re-open.
You can do something like the following to verify what you set:
echo $FOO
If it doesn’t show up, check the file permissions.
ls –l .bash_profile
If it isn’t -rw-r--r—you’ll want to change it:
chmod 644 .bash_profile
Inside the shell, you can re-run the .bash_profile by executing:
.~/.bash_profile
The . command sources a shell script in your current environment. You can use that to quickly edit and test on the command line without quitting and re-opening the shell.