How to Export to $PATH Permanently Without .bashrc File

bashpath

I am trying to figure out macOS and want to install Composer which was not a problem….but I need the Laravel and Symfony installer and in the documentation it says that I need to export the variable in .bashrc file.

Normally that file is in /home/username/ directory on Linux

But where is the .bashrc file on the Mac? How to export to the PATH?

Best Answer

It should be stored in /Users/username/. To append something to your .bashrc file use

echo foo >> ~/.bashrc

Make sure to use >> and not >, as the latter will overwrite the file.

As @fd0 said, you probably want this in your .bash_profile to make sure it loads. I would append to your .bash_profile like this:

echo "export PATH="$HOME/path/added:$PATH"" >> ~/.bash_profile