bgavea
Last Updated: February 25, 2016
·
1.171K
· sadfuzzy
Why s

Occasionally removed all Brew links?

Subject

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

Explanation:

  • 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 https://gist.github.com/4402228
Say Thanks
Respond

2 Responses
Add your response

2859
Photo on 08.01.2013 at 04.15

Isn't brew list | xargs brew link enough?

over 1 year ago ·
2861
Why s

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

over 1 year ago ·