Skip to content

Instantly share code, notes, and snippets.

@rainchen
Created August 28, 2013 09:13
Show Gist options
  • Select an option

  • Save rainchen/6363948 to your computer and use it in GitHub Desktop.

Select an option

Save rainchen/6363948 to your computer and use it in GitHub Desktop.
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
Copy Markdown

great formula!!! Thanks!

@tnine
Copy link
Copy Markdown

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
Copy Markdown
Author

@tnine just add the code into ~/.bash_profile

@reubenbrown
Copy link
Copy Markdown

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