Where the MAC environment variable is saved
When there is no zsh, the environment variables in the Mac are saved in the
1./etc/profile (it is not recommended to modify this file)
A global (public) configuration that reads the file when logged on, regardless of the user.
2./ETC/BASHRC (typically add system-level environment variables to this file)
Global (public) configuration, which will be read by the bash shell, regardless of the way it is executed.
3.~/.bash_profile (typically add user-level environment variables to this file)
Each user can use the file to enter shell information that is specific to their own use, and when the user logs in, the file executes only
If you want to modify the environment variable, the general modification ~/.bash_profile
is OK.
View environment variables
$ printenv
Echo $SHELL/bin/zsh
View the currently used shell
Zsh after installation
When ZSH is installed, it is not automatically read by default ~/.bash_profile
.
There should be directories in the user directory .oh-my-zsh
, and .zshrc
configuration files
.oh-my-zsh
Directory: It is the installation folder of Zsh and can change itself
.zshrc
: Inside is zsh default configuration, can be used to set environment variables (export), alias command aliases, set themes, etc.
However, ZSH does not recommend the direct operation of this default configuration, if users need custom configuration, recommended to go here./oh-my-zsh/custom/custom.zsh Modify.
Note: All configurations in the custom folder will be automatically read and configured by ZSH.
./oh-my-zsh/custom/my_custom.zsh
: User-defined custom system variables, custom commands, and more
In general, we ./oh-my-zsh/custom/my_custom.zsh
configure a shortcut key in
Alias zshconfig="subl ~/.oh-my-zsh/custom/my_custom.zsh"
In summary, if you want to configure the environment variable
- Execute
zshconfig
, the configuration file is opened automatically using the command you defined
- Add the environment variables you want to add to the file, such as
export ANDROID_HOME=/Development/android-sdk/
- Restart CMD, take effect! Ok. Configuration complete
Back up a configuration file of my own
./oh-my-zsh/custom/my_custom.zsh
As follows:
Alias zshconfig="subl ~/.oh-my-zsh/custom/my_custom.zsh"alias code=\ " /applications/visual Studio code.app/contents/resources/app/bin/code'alias subl= ' '/applications/sublime text.app/contents/sharedsupport/bin/subl '"alias NW= " /applications/nwjs.app/contents/macos/nwjs " Export Android_home=/development/android-sdk/
Okay, you can use the command line.
Code xxx/file. txt
It's a quick way to Vscode.
MAC environment variable Configuration