Wondering where the .zshrc file on your Mac is? If you are a Mac command line user who is interested in using and customizing the zsh shell, or using something like Oh My Zsh, you may be curious to know what and where the .zshrc file is and how to access it so you can customize your shell.
If you’re a regular Terminal user, you’ve probably noticed that zsh is now the default shell in MacOS Terminal (and yes, you can change the shell to bash, tcsh, ksh, zsh, etc. if you want, but we’re focusing on zsh, by default) .
By default, the .zshrc file does not exist for the standard user, even if you run the zsh shell. This may come as a surprise, but since the .zshrc file is used to configure the zsh shell, you will need to create it manually in your home directory before zsh can access it. There is also a zshrc file at the system level, but users change it less often.
Note that if you install Oh My Zsh, a .zshrc file will be created automatically for you.
Where is the .zshrc file on the Mac?
The .zshrc file will be located in the user’s home directory, or ~ /, and this user’s .zshrc file is where you will set the z-shell adjustments.
So the user .zshrc file will be on the following path:
If you have not already created a .zshrc file manually, the file will not exist by default.
You can create it with:
Or by running a text editor to create .zshrc, as nano:
You can then put anything you want in a .zshrc file, for example, any aliases, path modifications, export customizations, ZSH_THEME configurations, etc.
The changes will take effect when you reload the zsh profile or start a new terminal window.
Where is the universal zshrc file for the whole system?
While a customizable .zshrc file is located in the user’s home directory, there is also a system-level zshrc file.
The system zshrc file is located in the following path in macOS:
Any modification made to / etc / zshrc will be applied to the zsh shell for all users, regardless of whether they have an individual user level .zshrc file in their home directory.
Generally speaking, it is not recommended to change / etc / zshrc, and instead all user-level notifications for zsh should be made in the user’s .zshrc file located at the root of their home directory.
What about setting environment variables using zsh?
You can set zsh environment variables to:
You can modify this file with any command line text editor, such as nano, vim, emacs.
For example, you can add:
Here you can learn more about setting environment variables.
Friendly communicator. Music maven. Explorer. Pop culture trailblazer. Social media practitioner.