Homebrew is the best package manager for Mac. Before installing brew make sure XCode is installed. Nowadays, I have switched to Spack for installing scientific software since brew does not have all I need. I only install a few packages from brew, see below.

Here are some useful commands.

brew install gcc          -- Install some package, e.g., gcc
brew uninstall gcc        -- Uninstall a package
brew info gcc             -- Check package information
brew list                 -- List all installed packages
brew update               -- Update package list (needs internet connection)
brew outdated             -- See outdated packages
brew upgrade              -- Upgrade all outdated packages
brew upgrade gcc          -- Upgrade a specific package
brew cleanup              -- Remove old versions of packages
brew deps gcc             -- Check dependencies for gcc
brew uses --installed gcc -- Check which installed packages depend on gcc
brew leaves               -- List packages not required by any installed package

We will only install some basic packages from Homebrew and the rest of the scientific softwares using Spack.

brew install astyle
brew install chapel
brew install colordiff
brew install dos2unix
brew install gcc
brew install gv
brew install gnuplot --with-x11
brew install wget

Do not install any MPI library since Spack will install it for you.