Last active
February 14, 2017 17:44
-
-
Save turboMaCk/2b1f2f86ad62f9497f8977e757601de1 to your computer and use it in GitHub Desktop.
Reinstall all home brew packages
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 | |
# Reinstall all brew packages and dependencies in the correct order | |
# - list all installed packages | |
# - print the package followed by its dependencies | |
# - print the package and a single depenency on each line | |
# - perform a topographical sort | |
# - print out each package in the correct order on a single line | |
# - pass to brew reinstall | |
brew list \ | |
| while read package; do echo -n "$package "; echo $(brew deps $package); done \ | |
| awk 'NF == 1 {print $1, $1} NF > 1 {for (dep=1; dep<=NF; dep++) print $1, $dep}' \ | |
| tsort \ | |
| REINSTALL_LIST=$(while read package; do echo -n "$package "; done) \ | |
| brew reinstall $REINSTALL_LIST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment