On Install R and Python via Homebrew 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.
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.
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.