MacOS – Removing the builtin command-line utilities from PATH, zsh

homebrewmacospathzsh

Okay, so I'm a Linux power user, that is I feel most at home when I have access to the command-line, and I'm very much used to using GNU coreutils, so now that I've installed GNU coreutils on Mac OS X using Homebrew, how would I go about removing the builtin coreutils that vanilla Mac OS X comes with?

Please keep in mind that I'm using zsh, so when I set the path to something I do it like this:

path=(/usr/local/bin ~/.gem/ruby/2.0.0/bin ~/.nvm/bin ~/bin /bin $path)

I want to be able to say,

Include everything present in the current path in the new path, excluding these files: /usr/bin/ls, /usr/bin/grep

Best Answer

Add the following to your path to replace the OS X tools with Homebrew Coreutils:

$(brew --prefix coreutils)/libexec/gnubin

Per zsh syntax…

path=($(brew --prefix coreutils)/libexec/gnubin $path)