Skip to content

Instantly share code, notes, and snippets.

@canering
Forked from danmactough/movebrew
Created September 13, 2016 02:47
Show Gist options
  • Save canering/2497a247c57c62467b984d38f420bbcf to your computer and use it in GitHub Desktop.
Save canering/2497a247c57c62467b984d38f420bbcf to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get Homebrew in the new location
git clone [email protected]:Homebrew/homebrew.git ~/Homebrew
# Move all your installed packages to the new location
mv /usr/local/Cellar ~/Homebrew/Cellar
mv /usr/local/Library ~/Homebrew/Library
# Remove "root" directory files left behind
rm -rf /usr/local/.git /usr/local/{.gitignore,.yardopts,CODEOFCONDUCT.md,CONTRIBUTING.md,LICENSE.txt,README.md,SUPPORTERS.md}
# Remove all the now-broken symlinks
brew prune
# Create a symlink to `brew` executable from /usr/local/bin -- seemed like a good idea...
# https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md#untar-anywhere-and-then-symlink-the-brew-command-elsewhere
ln -sf ~/Homebrew/bin/brew /usr/local/bin/brew
# Fix all your symlinks :)
for $PKG in $(brew list); do brew link $PKG; done
# Symlink the important folders
ln -s ~/Homebrew/Cellar /usr/local/Cellar
ln -s ~/Homebrew/Library /usr/local/Library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment