Cache result of brew --prefix

brew --prefix runs Ruby, which is fairly expensive in system startup (somewhere
around 50-100 milliseconds on my machine). Instead of calling it twice, cache
the output and reuse it in the second command