$PATH in zsh

I am attempting to get zsh to add the ~/bin directory to my path. I added ~/bin to /etc/paths and it shows up when I echo $PATH in zsh:


echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin


Yet, zsh continues to report command not found when I attempt to run a script found in ~/bin.


If I chsh -s /bin/bash, it works without issue.


I ran across some posts suggesting to use ${Home}/bin instead of ~ in zsh but that did not appear to work either.


Any suggestions?

MacBook Pro with Touch Bar

Posted on Mar 15, 2021 12:02 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 15, 2021 2:47 PM

First of all, Zsh does not read the Bash dotfiles as it has its own, and secondly, here is what my ~/.zshrc PATH setting reflects:


export PATH="$HOME/bin:/usr/local/bin:$PATH"


You can invoke this new PATH in the current Terminal session with:


source ~/.zshrc


With this PATH, you can run anything in ~/bin from anywhere in the Terminal.


Zsh will read the ~/.zshrc file whether switching between shells, or when you launch the Terminal application.

5 replies
Question marked as Top-ranking reply

Mar 15, 2021 2:47 PM in response to mac_user61

First of all, Zsh does not read the Bash dotfiles as it has its own, and secondly, here is what my ~/.zshrc PATH setting reflects:


export PATH="$HOME/bin:/usr/local/bin:$PATH"


You can invoke this new PATH in the current Terminal session with:


source ~/.zshrc


With this PATH, you can run anything in ~/bin from anywhere in the Terminal.


Zsh will read the ~/.zshrc file whether switching between shells, or when you launch the Terminal application.

Mar 15, 2021 3:21 PM in response to mac_user61

I am not referring to any bash dot files. /etc/paths is a MAC OS implementation and, as far as I know, is not shell dependent. The path variable in my zsh shell shows ~/bin was added to the path after editing /etc/paths. (I also added ${HOME}/bin).


dnelson@laptop ~ % echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin:${HOME}/bin

dnelson@laptop ~ % power

zsh: command not found: power

dnelson@laptop ~ % ~/bin/power

Chassis Power Control: Up/On

Chassis Power Control: Up/On

Chassis Power Control: Up/On

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.

$PATH in zsh

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