How to set a path to the $PATH in iOS Monetary permanently? The shell I use is zsh

When using the syntax of exporting a new Path, the path would be removed after restarting the terminal and the Mac also.

How to set a new path in the zsh? Please be clear, because the ~/profile or zprofile or etc/paths or etc/paths.d and other tries are USELESS . Apple itself has got no support for this issue and I have talked to them and I can report their answer also. They refer me to the user guide of zsh which is a kind of labyrinth or a maze


Please any one who can explain the mechanism of how to add a path to the existing $PATH environment variables permanently.

Thanks in advance


MacBook Pro 15″, macOS 12.1

Posted on Jan 24, 2022 3:25 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 24, 2022 7:42 AM

The Zsh shell requires its own dotfile in your home directory to read the PATH environment variable on each launch of the Terminal or new Terminal window. It does not read the older Bash dotfiles for the PATH.


Create a new plain text file in your home directory with the name:

.zshrc


and enter the following in it before you save it.

export PATH="${PATH}"
PS1="%m: %~ %% "


Once you have done that, you can set it in the current Terminal window:

source ~/.zshrc


In the Terminal, your home directory Terminal prompt will now show your hostname: ~ % and because the PATH is now set, you can access commands in the Terminal.


If you wanted to access the path /usr/local/bin before the PATH variable, then this would be the approach in that .zshrc file:


export PATH="/usr/local/bin:${PATH}"



Similar questions

2 replies
Question marked as Top-ranking reply

Jan 24, 2022 7:42 AM in response to thephantom211

The Zsh shell requires its own dotfile in your home directory to read the PATH environment variable on each launch of the Terminal or new Terminal window. It does not read the older Bash dotfiles for the PATH.


Create a new plain text file in your home directory with the name:

.zshrc


and enter the following in it before you save it.

export PATH="${PATH}"
PS1="%m: %~ %% "


Once you have done that, you can set it in the current Terminal window:

source ~/.zshrc


In the Terminal, your home directory Terminal prompt will now show your hostname: ~ % and because the PATH is now set, you can access commands in the Terminal.


If you wanted to access the path /usr/local/bin before the PATH variable, then this would be the approach in that .zshrc file:


export PATH="/usr/local/bin:${PATH}"



This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to set a path to the $PATH in iOS Monetary permanently? The shell I use is zsh

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