Where is .zshrc file located in macOS

If you are using the Zsh shell, the default shell for Mac since the release of macOS Catalina, and trying to locate the .zshrc file, you must first know that this file is not created by default, you need to create one, if you think you already created one and want to locate it, here is how you can do that,

✌️ Note: If you install Oh My Zsh the zshrc file is auto-created.

How to locate the user level .zshrc file?

  1. Open Spotlight Search,
  2. Type Terminal and open it,
  3. Now type cd ~ to move to your user folder,
  4. Type ls -a, to see all the files (-a option to see hidden files),
  5. You should be able to see the .zshrc file, if not you do not have it

You can type just one command to view the files content,

% cat ~/.zshrc

If the file is not present you will get the below error!

cat: /Users/code2care/.zshrc: No such file or directory
Location of .zshrc fie macOS

An easy way to create and add text to the file is by nano (or vi) text editor nano ~/.zshrc

✌️I changed the prompt of Zsh from % to an emoji: 🦋, if you would like to do something similar follow the article: https://code2care.org/zsh/how-to-set-an-emoji-as-zsh-terminal-prompt-macos

Below is a ls command piped with grep tp see all the hidden .zsh files on a Mac using Terminal command.

% ls -la | grep '\.zsh.*'

-rw-r--r--   1 code2care  staff     38 Mar 12  2022 .zprofiley
-rw-------@  1 code2care  staff  21198 Oct 10 13:29 .zsh_history
drwx------  43 code2care  staff   1376 Oct 12 17:34 .zsh_sessions
-rw-r--r--   1 code2care  staff     29 Jun 27 22:48 .zshenv
-rw-r--r--   1 code2care  staff    266 Sep 11 16:39 .zshrc
-rw-r--r--   1 code2care  staff     42 Jan 26  2022 .zshrcy
Locate Local dot zsh files Mac

How to locate the system level .zshrc file?

You can find the system level .zshrc file where all the system's configuration files live i.e. the /etc

  1. Open Mac Terminal,
  2. Move to /etc directory: cd /etc
  3. You will find a zshrc file here (this is not a hidden file),
  4. Open this file using nano or vim editor: vi zshrc
System Level zshrc file editing using nano editor example

Note: If you make any changes in the /etc/zshrc file, the changes will be applied to all users on the Mac even if the .zshrc file is not available for any user or now.


Have Questions? Post them here!

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram