Is there a quick way to relink my homebrew kegs? I just upgraded my MacBook Air to Mavericks.  The process appears to have removed almost all of the symlinks that homebrew put in /usr/local/bin.  As I notice things missing then I relink them via brew unlink &lt;keg&gt; &amp;&amp; brew link &lt;keg&gt; (although the symlinks are gone, homebrew still thinks they are there so I need to unlink first).  This feels somewhat inefficient.

I could just loop through everything in /usr/local/Cellar but not every keg is automatically linked and I don't want to link those.  So my next guess is to list every linked keg and relink them (using the above).

Is there some magic command that will find all the kegs that homebrew thinks are linked so that I can relink them?
This bash command (taken from there) will unlink all installed formulas and then link them again:

brew list -1 | while read line; do brew unlink $line; brew link $line; done


I guess all formulas need to be linked, otherwise, whichever tool depends on them, won't be able to find them..