To temporarily set the path environment variable on macOS:
The way that macOS recommends is to add a file into the “/etc/paths.d/” directory. When you start a new terminal session, macOS will automatically read these files and add the folders to your path environment variable.
- Create a file under /etc/paths.d directory
sudo nano /etc/paths.d/addmore
- Add paths to the file. Multiple lines allowed
- After making these changes, save and quit by pressing CTRL + X, followed by Y, then the ENTER key.
- Only new sessions will see the addition to the path. Currently running sessions will not.