-
-
Save sorah/48b372dbe5b304afa3ac to your computer and use it in GitHub Desktop.
Homebrew relink if necessary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for keg in /usr/local/Library/LinkedKegs/*; do | |
kegname="$(basename $keg)" | |
dir="$(find $keg/ -maxdepth 1 -type d | grep '\/\(sbin\|bin\|etc\|var\|lib\|include\|libexec\|share\)$' | head -n1)" | |
[ -z "${dir}" ] && continue | |
testee="$(find $dir -type f | head -n1 | sed -e "s|${keg}||")" | |
[ -f /usr/local/$testee ] || (echo $keg && brew unlink $kegname; brew link --force $kegname) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment