I installed gcc with homebrew:
$ brew install gcc
I can see the result:
$ brew list ant gcc go libyaml postgresql tmux autoconf gdb isl mpfr python valgrind automake gdbm libevent openssl readline wget binutils git libmpc ossp-uuid ruby xz cloog gmp libtool pkg-config sqlite
I also see
$ ls /usr/local/bin ... gcc-4.9 ...
The issue is that typing
gcc still refers to the system gcc
$ which gcc /usr/bin/gcc
I wanted to rename
gcc, but I don't want to break anything in homebrew. Specifically, I'd like to rename it in such a way that homebrew is aware of the change and running
brew update will know to link the newly updated version to the name
Can this be done?
$ which gcc /usr/local/bin/gcc $ gcc -v ... version XXX $ brew update ... new gcc version YYY installed in /usr/local/bin/gcc $ which gcc /usr/local/bin/gcc $ gcc -v ... version YYY
I don't think what you want can be done directly without hacking Homebrew formulas, er, I mean formulae.
What I do is put
in my shell profile. That works in almost all scenarios I'm interested in.
An alternative is that you create your own "bin" directory, say
~/bin/, put that first in the path, and symlink
Both of these methods will survive package upgrades.