Install GNU and non-GNU Tools via Homebrew

OS X
Install GNU and non-GNU tools using Homebrew, and save yourself a headache and valuable time when you need newer software versions.
Author

Mauricio “Pachá” Vargas S.

Published

July 15, 2017

Updated 2022-05-28: Updated links.

Why should you do this?

On a previous post about installing R and Python on OS X I described some potential problems when using R or Python libraries.

After doing a fresh OS X install I had some problems with LATEX and XQuartz. The root of the problem is directories location that is easily solved with Homebrew as it doesn’t touch the system and provides symlinks for its packages.

What do you need to do this?

You’ll need Homebrew and XCode installed. How to do that? check these links

Its possible to install just Command Line Tools for XCode from Apple Developers instead of full XCode. The script below contains a line to install that.

How do you do this?

This script will install coreutils, bash, git and more updated tools. Don’t forget to read How to install and codesign GDB on OS X El Capitan to make it work.

# See http://pacha.hk/2017-07-15_gnu_nongnu_homebrew.html
# XCode CLT
xcode-select --install
# Update Homebrew and add formulae
brew update
# Check for broken dependencies and/or outdated packages
brew doctor
brew prune
# Core tools
brew install coreutils
brew install binutils
brew install diffutils
brew install ed --with-default-names
brew install findutils
brew install gawk
brew install gnu-indent --with-default-names
brew install gnu-sed --with-default-names
brew install gnu-tar --with-default-names
brew install gnu-which --with-default-names
brew install gnutls
brew install grep --with-default-names
brew install gzip
brew install screen
brew install watch
brew install wdiff --with-gettext
brew install wget
# Additional tools
brew install bash
brew install emacs
brew install gdb # gdb requires further actions to make it work. See `brew info gdb`. Follow this link for instructions https://medium.com/@royalstream/how-to-install-and-codesign-gdb-on-os-x-el-capitan-aab3d1172e95#.jbzcfeegv
brew install gpatch
brew install m4
brew install make
brew install nano
# Non-GNU tools
brew install file-formula
brew install git
brew install less
brew install openssh
brew install perl518
brew install rsync
brew install svn
brew install unzip
brew cask install texlive
brew cask install inkscape
echo 'export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/file-formula/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/perl@5.18/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/ncurses/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/unzip/bin:$PATH"' >> ~/.bash_profile
echo 'export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"' >> ~/.bash_profile
echo 'export MANPATH="/usr/local/opt/make/libexec/gnuman:$MANPATH"' >> ~/.bash_profile
sudo launchctl config user path /usr/local/opt/coreutils/libexec/gnuman:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin