What you've laid out is the proper way to add additional directories to your user's
Step 1 -
To start make edits to your
~/.bash_profile adding whatever locations you'd like to have amended to your
Step 2 - source
After making the above edits to this file you can either use the
source command or the
. notation to "reload" and changes made to this file in your current shell's context.
$ . ~/.bash_profile
$ source ~/.bash_profile
Step 3 - Evaluate changes
After making the edits and sourcing them you can confirm they had the effect you desired by echoing the contents of the
$ echo $PATH | tr ':' '\n'
/Applications/Visual Studio Code.app/Contents/Resources/app/bin
The order matters, so directories that occur first will be searched first. If a binary lives in multiple places, the first place encountered will be the one that is used.
Also keep in mind that multiple sourcings of this file will have a negative effect of continuing to add the same changes, so it's often the case that you'll want to completely se the
$PATH to a consistent known initial state and then amend it with these types of commands:
macOS also includes a helper to assistance in the management of your
$PATH. It's located here
So instead of manually crafting your base
$PATH as mentioned above you can instead use this snippet to get a known good starting point for your
[ -x /usr/libexec/path_helper ] && eval $(/usr/libexec/path_helper -s)
This will take care to initialize
$PATH so any directories listed in
/etc/paths.d/ get added automatically.