Wondering where the .zshrc file is located on a Mac? If you’re 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 located, and how to access it so that you can customize your shell.
If you’re a regular Terminal user, you probably noticed that zsh is now the default shell in MacOS Terminal app (and yes you can change the shell to bash, tcsh, ksh, zsh, etc if you want to, but we’re focusing on zsh, the default).
By default, the .zshrc file does not exist for a standard user, even if you launch the zsh shell. This may come as some surprise, but since the .zshrc file is used to configure the zsh shell, you’ll need to manually create one in your home directory for zsh to access. There’s also a system-level zshrc file, but that is less commonly modified by users.
Do note that if you install Oh My Zsh, a .zshrc file will be created automatically for you.
Where is the .zshrc file on a Mac?
The .zshrc file will be located in the users home directory, or ~/, and this user .zshrc file is where you’d place customizations to the z shell.
Thus, the user .zshrc file will be in the following path location:
If you have not yet manually created a .zshrc file, the file will not exist by default.
You can create one with:
Or by launching a text editor to create .zshrc, like nano:
You can then place whatever you’d like to in the .zshrc file, for example, any aliases, path modifications, export customizations, ZSH_THEME configs, etc.
Changes will take effect when you reload zsh profile or launch a new terminal window.
Where is the universal system-wide zshrc file?
While the user customizable .zshrc file resides in the users home directory, there is also a system level zshrc file.
The system zshrc file is located at the following path in macOS:
Any modification made to /etc/zshrc will apply to the zsh shell for all users, regardless of whether or not they have an individual user level .zshrc file in their home directory.
Generally speaking, it is not recommended to modify /etc/zshrc, and instead all user level notifications to zsh should be made in the user .zshrc file found in the root of their home directory.
What about setting environment variables with zsh?
You can set environmental variables for zsh at:
You can modify that file with any command line text editor, like nano, vim, emacs.
For example, you could add:
You can learn more about setting environment variables here.