Skip to content

Instantly share code, notes, and snippets.

@bsdf
Last active December 12, 2015 12:19
Show Gist options
  • Save bsdf/4771589 to your computer and use it in GitHub Desktop.
Save bsdf/4771589 to your computer and use it in GitHub Desktop.
adds 'cd' command to brew which lets you cd into a formula's directory
unfunction brew &> /dev/null
orig=$(which brew)
function brew() {
if [[ $1 = 'cd' ]]; then
dir=$($orig --prefix $2)
if [[ $? -eq 0 ]]; then
# cd to the formula's prefix
cd $dir
else
# formula doesn't exist so print brew's error
$orig --prefix $2
fi
else
# pass on command to brew
$orig $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment