How to make brew install a package only if it is not yet installed, and upgrade otherwise?
Solution 1:
Homebrew doesn't support that way of use.
To reduce keypresses you could leverage SHELL-scripting (makes sense to add to your SHELL's .rc-file), say:
brewIn() { if brew ls --versions "$1"; then brew upgrade "$1"; else brew install "$1"; fi }
— Works both in Bash and Zsh. Usage: brewIn …formulae…
. But none except this.