Before Catalina, environment variables were always set in the following files:
~/.bash_profile
Copy the code
10.15 Comparison with earlier Versions:
~/.bashrc -> ~/.zshrc
~/.bash_profile -> ~/.zprofile
Copy the code
Due to the habit, after reinstalling the system, the Mac Os version was upgraded to 10.15. However, setting environment variables according to the previous method still did not take effect, so I checked the system update log:Use ZSH as the default Shell on the Mac
Alternative: Since the ZSHRC file is executed every time the terminal is opened, simply refresh the previous environment variables.
vi ~/.zshrc
source ~/.bash_profile
Copy the code
Priority:
The following three are system-level configuration files, which are loaded upon system startup.
/etc/profile/
/etc/paths
/etc/bashrc
If the # bash_profile file exists, the following files are ignored.~/.bash_profile or ~/.bashrc ~/.bash_login ~/.bash_profileCopy the code
You only need to edit the configuration file of the new version for user environment variables. You are not advised to modify the /etc/profile and /etc/bashrc files for global environment variables. You can modify the /etc/paths file and add your own path to the last line of the /etc/paths file. You can also add the corresponding path by adding the app name file to /etc/paths.d. If you want to add the mysql running path to path, do this:
Sudo touch /etc/paths.d/mysql (the name is the name of the app to be executed) sudo vi /etc/paths.d/mysql/usr/local/mysql/bin
Copy the code