How to modify the PATH environment variables in Catalina?
As you said in your own self-answer, you don't need to know where the PATH
variable is originally populated.
You may easily add new paths to the PATH
at either end or beginning, and zsh
also has a convenient way of removing duplicates.
You may make the PATH
variable, and the associated path
array, unique first, by using
typeset -U -g PATH path
The variables will then stay unique by virtue of this command.
To prepend a couple of paths:
path=( /new/path1 /new/path2 $path )
To append a couple of paths:
path=( $path /new/path1 /new/path2 )
or,
path+=( /new/path1 /new/path2 )
The PATH
variable's value will be updated accordingly.
You may want to do this in your $ZDOTDIR/.zprofile
file, which is sourced automatically by any zsh
login shell. Doing it in your $ZDOTDIR/.zshenv
file would be unnecessary as that file is sourced by any type of zsh
invocation (and should therefore be kept really short, if it's needed at all; I just set ZDOTDIR=$HOME/.zsh
in there, for example).
Note that PATH
is already an environment variable, so exporting it again serves no purpose.