Skip to content

Instantly share code, notes, and snippets.

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
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
Copy link

rainchen commented Oct 30, 2013

@tnine just add the code into ~/.bash_profile

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