Skip to content

Instantly share code, notes, and snippets.

@SuperSpyTX
Last active July 17, 2017 03:50
Show Gist options
  • Save SuperSpyTX/efa4754d661abec321d510f0e31b116e to your computer and use it in GitHub Desktop.
Save SuperSpyTX/efa4754d661abec321d510f0e31b116e to your computer and use it in GitHub Desktop.
Take your homebrew applications with you on any lab computer

Have this code handy in your PATH or somewhere (you can save this as brewinstall):

#!/bin/bash
if [ ! -e '$HOME/goinfre' ] ; then
    mkdir /goinfre/$(whoami)
fi
if [ ! -d '$HOME/goinfre/brew/bin' ] ; then
    git clone https://github.com/Homebrew/homebrew.git ~/goinfre/brew
    brew update
fi
mkdir -p $HOME/var/homebrew
mkdir -p $HOME/goinfre/locks
rm -f $HOME/var/homebrew/locks
ln -s $HOME/goinfre/locks $HOME/var/homebrew/locks

Then just symlink brew to the one that would be in goinfre. ln -s $HOME/goinfre/brew/bin/brew $HOME/bin/brew

Then add that to your path but with the symlinked path. Adjust accordingly in your .zshrc file.

# This is where you can store the brew symlink in the next code block.
export PATH="$HOME/bin:$PATH"

# I'm just hardcoding my applications, but this is a good way to 
export PATH="$HOME/.gem/ruby/2.0.0/bin:$PATH"
export PATH="$HOME/Cellar/valgrind/3.13.0/bin:$PATH"
export PATH="$HOME/Cellar/neovim/HEAD-144f584/bin:$PATH"

Use the first script above on any lab computer without brew installed. It will remove and reinstall the symlinking portion so homebrew can actually just run off your home folder. The reason for the locks folder to be symlinked is so it can obtain a lock for installing applications. This should be installing applications under Cellar in your home folder. Use the example from my .zshrc file to add these applications (or I think brew will make a bin folder for you 🤔)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment