Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install specific version of Homebrew formula
# Install specific version of Homebrew formula
# usage example:
# $ brew-install ssh-copy-id 6.0p1
function brew-install {
local formula version formula_hash
formula=$1
version=$2
cd `brew --prefix`
git_last_commit_id=`git rev-parse --short HEAD`
formula_hash=`brew versions $formula|grep $version|awk '{print $4}'`
echo brew install $formula with version $version $formula_hash
git checkout $formula_hash Library/Formula/$formula.rb
brew install $formula
brew switch $formula $version
git checkout $git_last_commit_id Library/Formula/$formula.rb # reset formula
cd - # got back to previous dir
}
@micheleorsi
Copy link

micheleorsi commented Sep 5, 2013

great formula!!! Thanks!

@tnine
Copy link

tnine commented Oct 23, 2013

Dumb question, but where do I install this so that it's picked up on the path?

@rainchen
Copy link
Author

rainchen commented Oct 30, 2013

@tnine just add the code into ~/.bash_profile

@reubenbrown
Copy link

reubenbrown commented Jan 15, 2015

Been looking everywhere for something like this. Thanks!

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