EDIT:
I have now deleted the $HOME/bin:/usr/local/bin:
portion from line 1 of my .zshrc
file. So now that line reads as export PATH=$PATH
. This got rid of the duplicates, but it still doesnt explain where Mono and Postgres are being added to the path.
Here is what the path outputs in readable formatting:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Library/Frameworks/Mono.framework/Versions/Current/Commands:
/Applications/Postgres.app/Contents/Versions/latest/bin
Is there another file that is handling the exportation of these paths?
ORIGINAL:
So I really couldn't come up with a very good title, so if anyone has any suggestions please leave them in the comments.
So heres my problem. I just reset my .zshrc
file to the default template by using the following command.
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
So here is my file contents for .zshrc
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="agnoster"
plugins=(
git
)
source $ZSH/oh-my-zsh.sh
The following files are either completely empty or have everything commented out: .zprofile
, .bash_profile
, .bashrc
.
After running the source .zshrc
command in my terminal followed by the echo $PATH
command, this is my output.
/Users/jrobinson/bin:/usr/local/bin:/Users/jrobinson/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Postgres.app/Contents/Versions/latest/bin
Let's format this a little better so we can see what's going on:
/Users/jrobinson/bin:
/usr/local/bin:
/Users/jrobinson/bin:
/usr/local/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Library/Frameworks/Mono.framework/Versions/Current/Commands:
/Applications/Postgres.app/Contents/Versions/latest/bin
As you can see, some things are repeating such as /usr/local/bin
& /Users/jrobinson/bin
.
Also I had at one point Postgres installed on my computer, but no longer have it installed. Mono I still have and use, but I have no idea where it's being added to my path.
The only thing I'm defining in my path is: export PATH=$HOME/bin:/usr/local/bin:$PATH
So why am I getting these repeat things? I'm assuming it's because of some repeating code somewhere in some file, and I can't pin point where these repeats are occurring so I can delete them and clean up my PATH.
ALSO which is really weird, I have Composer installed on my computer as well, and I can use the composer
command even though I haven't defined Composer in my path with /.composer/vendor/bin
.
path_helper
is a helper for constructing PATH
environment variable. It's macOS exclusive.
man path_helper
Files in these directories should contain one path element per line.
Prior to reading these directories, default
PATH
andMANPATH
values are obtained from the files/etc/paths
and/etc/manpaths
respectively.
A GUI app could put files into these paths. When a shell starts up, values within will be added into PATH
, or MANPATH
by path_helper
. The whole point seems to be avoiding polluting /usr/bin
or /usr/local/bin
by creating symlink into them.
For bash, path_helper
is called in /etc/profile
on shell startup. For zsh, path_helper
is called in /etc/zprofile
.
Content of /etc/profile
:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
path_helper -s
-s Generate Bourne shell commands on stdout. This is the default if SHELL does not end with "csh".
References
man path_helper