Last Updated: February 25, 2016
· sadfuzzy

Occasionally removed all Brew links?


If you, like me (during RMagick gem and ImageMagick lib install) removed all Brew links from /usr/local/bin, use this script to generate them back:

$ find /usr/local/Cellar | grep bin/ > ./usr_bin_local
$ ruby -ne "s=\$_; p=s.match(/\/bin\/(.+)/); b=p[1] unless p.nil?; cmd=%Q(ln -s #{s.chomp} /usr/local/bin/#{b});`#{cmd}`" ./usr_bin_local


  • 1st line finds all the bins in standart Brew packages installation directory on Mac OS X 10.7.x and saves them to 'usrbinlocal' file
  • 2nd line runs ruby script, that finds bin name and creates link to its path in /usr/local/bin
  • Profit!

Get a Gist:

$ git clone

2 Responses
Add your response

Isn't brew list | xargs brew link enough?

over 1 year ago ·

@sheerun, my script is for those, who have nothing in /usr/local/bin at all

over 1 year ago ·