With Homebrew, how to check if a software/package is installed?
you could do something like this: 

brew list &lt;formula1&gt; || brew install &lt;formula1&gt;


This will error on list and continue with install if not installed otherwise it will just list package files. (one could modify this further as a function or alias in .bashrc to make it easier to type)