I would like to use Homebrew to install GNU versions of several utilities, and use the GNU versions by default with their usual names.
From the output of brew install gnu-tar and by reading How to replace Mac OS X utilities with GNU core utilities? I learned that I can add /usr/local/opt/gnu-tar/libexec/gnubin to my $PATH variable. However, for other packages, the gnubin directory is under a different path, like /usr/local/opt/coreutils/libexec/gnubin for the coreutils package.
Do I have to add each of these to my path by hand, or does Homebrew provide an easy way to collect all of the entries in various gnubin directories into one place?
I suppose I could put some kind of auto-finding script in my .bash_profile like:
GNUBINS=$(find -L /usr/local/opt -type d -name gnubin | tr ' ' ':')
export PATH=$GNUBINS:$PATH
However this feels a little clunky and insecure, and I was hoping for a Homebrew-specific solution.
gnubins it will put literally/usr/local/opt/*/libexec/gnubinon the path, but presumably one is only running this if one has at least onegnubinthere. :) (and furthermore, my originalfindcommand suffers from a similar issue) – amacleod Oct 09 '19 at 13:58