3

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...

4

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)
  • doesn't this just say brew install everything from now on in 'coreutils' That's not really what I want. I want some that says include everything in '/usr/bin' EXCEPT for this list of files – Alexej Magura Nov 11 '13 at 17:45
  • 1
    @AlexejMagura Adding $(brew --prefix coreutils)/libexec/gnubin to your existing path will mean that any GNU tool will replace the relevant tool found in /usr/bin. If it doesn't exist in GNU's bin, it will use /usr/bin. – grg Nov 11 '13 at 17:49
  • doesn't seem to work. Adding that to the path doesn't do anything, even if I add it after $path. – Alexej Magura Nov 11 '13 at 17:57
  • 2
    @AlexejMagura Adding it after your current path (i.e. $PATH) definitely won't work - it searches in the order given in your $PATH, so the GNU bin must be either the very first entry in $PATH, or at least before any location that you are attempting to override. – grg Nov 11 '13 at 17:59
4

First, you don't want to remove the any of the command line tools that apple provides unless you want an unstable / unusable system. However in traditional Unix/Linux fashion you can set up your path statement to check /usr/local/bin first, thus utilities installed there (default for homebrew) will be used before /usr/bin (or /bin). The remaining issue is in shell scripts - you must be explicit since they may ignore your $PATH.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .