You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal Shell Startup Files

Where in Apple documentation can I find the order in which the shell startup files are executing?

The macOS implementation of the zsh shell appears to be slightly different from the Sourceforge "standard".

For example, /etc/zshenv "should" always load first; however, macOS does not seem to have that file in /etc/ : the only 2 files I see in that directory are zprofile and zshrc although I also have a file zshrc_Apple_Terminal -- this is after I have opened the Terminal app and verified that


bernard@Bernards-iMac ~ % echo $SHELL
/bin/zsh


Incidentally, the only 2 zsh-related files I have in my home directory are:

.zsh_history
.zsh_sessions


Should there not be a file ~/.zshrc ?


Where could I read up more on the zsh shell and Apple's implementation of the shell?

iMac 21.5″ 4K, macOS 11.6

Posted on Sep 16, 2021 4:35 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 16, 2021 5:22 AM

I use two files, ~/.zshrc and ~/.zshenv which are read when you launch the Terminal application or switch between Bash and Zsh shells. Zsh does not read Bash startup files.


I put the PATH, PS1, aliases, history, etc in the ~/.zshrc file, and keep all Zsh shell functions and any default zmodload module entities in the ~/.zshenv.


Because Zsh is huge, its man page is articulated in multiple man pages. You can see these from the Terminal:


man zsh


Once your default shell is Zsh, the AppleScript do shell script is defaulting to Zsh, not Bash. Apple has for some unknown reason choosen to omit the PCRE Zsh module, even though the licensing is MIT. Apple does not provide any implementation details for Zsh. Use the PDF Manual documentation from the Zsh Sourceforge site.

Similar questions

5 replies
Question marked as Top-ranking reply

Sep 16, 2021 5:22 AM in response to BernardMR

I use two files, ~/.zshrc and ~/.zshenv which are read when you launch the Terminal application or switch between Bash and Zsh shells. Zsh does not read Bash startup files.


I put the PATH, PS1, aliases, history, etc in the ~/.zshrc file, and keep all Zsh shell functions and any default zmodload module entities in the ~/.zshenv.


Because Zsh is huge, its man page is articulated in multiple man pages. You can see these from the Terminal:


man zsh


Once your default shell is Zsh, the AppleScript do shell script is defaulting to Zsh, not Bash. Apple has for some unknown reason choosen to omit the PCRE Zsh module, even though the licensing is MIT. Apple does not provide any implementation details for Zsh. Use the PDF Manual documentation from the Zsh Sourceforge site.

Terminal Shell Startup Files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.